You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
k3s/vendor/github.com/bronze1man/goStrongswanVici/err.go

25 lines
319 B

package goStrongswanVici
import (
"fmt"
)
func handlePanic(f func() error) (err error) {
defer func() {
r := recover()
//no panic
if r == nil {
return
}
//panic a error
if e, ok := r.(error); ok {
err = e
return
}
//panic another stuff
err = fmt.Errorf("%s", r)
}()
err = f()
return
}