Skip to content

Instantly share code, notes, and snippets.

@sanbornm
Created March 16, 2020 19:30
Show Gist options
  • Save sanbornm/4a73cb182e68a72754e61ac134a2e77d to your computer and use it in GitHub Desktop.
Save sanbornm/4a73cb182e68a72754e61ac134a2e77d to your computer and use it in GitHub Desktop.
// 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