mirror of
https://github.com/netsampler/goflow2.git
synced 2024-05-06 15:54:52 +00:00
23 lines
421 B
Go
23 lines
421 B
Go
package debug
|
|
|
|
import (
|
|
"runtime/debug"
|
|
|
|
"github.com/netsampler/goflow2/v2/utils"
|
|
)
|
|
|
|
func PanicDecoderWrapper(wrapped utils.DecoderFunc) utils.DecoderFunc {
|
|
return func(msg interface{}) (err error) {
|
|
|
|
defer func() {
|
|
if pErr := recover(); pErr != nil {
|
|
|
|
pErrC, _ := pErr.(string)
|
|
err = &PanicErrorMessage{Msg: msg, Inner: pErrC, Stacktrace: debug.Stack()}
|
|
}
|
|
}()
|
|
err = wrapped(msg)
|
|
return err
|
|
}
|
|
}
|