mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-12 07:10:26 +00:00
Add TrapPanic
This commit is contained in:
parent
5084c30d94
commit
3aea8cbeca
@ -300,3 +300,11 @@ func ArgsOrIn(args []string) string {
|
||||
// strings.Fields) to ensure that hard-coded arguments containing
|
||||
// whitespace are properly handled.
|
||||
var Aliases = make(map[string][]string)
|
||||
|
||||
// TrapPanic recovers from any panic and more gracefully displays the
|
||||
// error as an exit message. Simply add defer TrapPanic() when wanted.
|
||||
var TrapPanic = func() {
|
||||
if r := recover(); r != nil {
|
||||
ExitError(r)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user