mirror of https://github.com/k3s-io/k3s
25 lines
319 B
Go
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
|
||
|
}
|