Skip to content
Snippets Groups Projects
Commit a43b2c14 authored by Jono Wenger's avatar Jono Wenger
Browse files

Add RunAndCatch

parent 29635852
No related branches found
No related tags found
1 merge request!3Release
...@@ -38,6 +38,13 @@ func CatchHandler(fn func(err error)) { ...@@ -38,6 +38,13 @@ func CatchHandler(fn func(err error)) {
} }
} }
// RunAndCatch runs the specified function and catches any exceptions thrown by
// Javascript.
func RunAndCatch(fn func() js.Value) (v js.Value, err error) {
defer Catch(&err)
return fn(), nil
}
func handleRecovery(r interface{}) error { func handleRecovery(r interface{}) error {
if r == nil { if r == nil {
return nil return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment