bpmodify: fix os.Exit() shouldn't shadow panic()
The `defer func() { os.Exit() }()` in main() method shadows panic(). Make the exit handler recover() from panic(), log the panic(), and then gracefully exit. Test: m bpmodify Change-Id: Icc89f8fce0b6096489baa0ba0f08c21d1ef623bc
This commit is contained in:
parent
aa919ddcbb
commit
9342b43c95
1 changed files with 6 additions and 1 deletions
|
@ -223,7 +223,12 @@ func walkDir(path string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defer func() { os.Exit(exitCode) }()
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
report(fmt.Errorf("error: %s", err))
|
||||||
|
}
|
||||||
|
os.Exit(exitCode)
|
||||||
|
}()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue