Skip to content

Commit

Permalink
Do not panic on runtime errors
Browse files Browse the repository at this point in the history
Panics are usually reserved for programming errors
(i.e. a bug in the code). This code path is frequently hit for
user errors, like running "git amend" with an empty staging area.

commit-id:e5019250
  • Loading branch information
leoluk committed Dec 18, 2021
1 parent 3f2bf32 commit 9734851
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,11 @@ func (sd *stackediff) mustgit(argStr string, output *string) {

func check(err error) {
if err != nil {
panic(err)
if os.Getenv("SPR_DEBUG") == "1" {
panic(err)
}
fmt.Printf("error: %s\n", err)
os.Exit(1)
}
}

Expand Down

0 comments on commit 9734851

Please sign in to comment.