k3s/vendor/github.com/bronze1man/goStrongswanVici/err.go
2019-09-27 18:33:04 -07:00

25 lines
319 B
Go

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
}