Created
March 16, 2020 19:30
-
-
Save sanbornm/4a73cb182e68a72754e61ac134a2e77d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wrap returns a new function which executes HandlerFunc before panicking. | |
func Wrap(fn func()) func() { | |
return func() { | |
// handle panics | |
defer func() { | |
if err := recover(); err != nil { | |
HandlerFunc(err) | |
pnic(err) | |
} | |
}() | |
fn() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment