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