v0.0.529 handle PanicWrappedErr in exerr.FromError()
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m13s

This commit is contained in:
Mike Schwörer 2024-10-08 19:22:17 +02:00
parent b8cb989e54
commit c8dec24a0d
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 48 additions and 2 deletions

View File

@ -19,6 +19,52 @@ func FromError(err error) *ExErr {
return verr
}
//goland:noinspection GoTypeAssertionOnErrors
if verr, ok := err.(langext.PanicWrappedErr); ok {
return &ExErr{
UniqueID: newID(),
Category: CatForeign,
Type: TypePanic,
Severity: SevErr,
Timestamp: time.Time{},
StatusCode: nil,
Message: "A panic occured",
WrappedErrType: fmt.Sprintf("%T", verr),
WrappedErr: err,
Caller: "",
OriginalError: nil,
Meta: MetaMap{
"panic_object": {DataType: MDTString, Value: fmt.Sprintf("%+v", verr)},
"panic_type": {DataType: MDTString, Value: fmt.Sprintf("%T", verr)},
"stack": {DataType: MDTString, Value: verr.Stack},
},
Extra: make(map[string]any),
}
}
//goland:noinspection GoTypeAssertionOnErrors
if verr, ok := err.(*langext.PanicWrappedErr); ok && verr != nil {
return &ExErr{
UniqueID: newID(),
Category: CatForeign,
Type: TypePanic,
Severity: SevErr,
Timestamp: time.Time{},
StatusCode: nil,
Message: "A panic occured",
WrappedErrType: fmt.Sprintf("%T", verr),
WrappedErr: err,
Caller: "",
OriginalError: nil,
Meta: MetaMap{
"panic_object": {DataType: MDTString, Value: fmt.Sprintf("%+v", verr)},
"panic_type": {DataType: MDTString, Value: fmt.Sprintf("%T", verr)},
"stack": {DataType: MDTString, Value: verr.Stack},
},
Extra: make(map[string]any),
}
}
// A foreign error (eg a MongoDB exception)
return &ExErr{
UniqueID: newID(),

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.528"
const GoextVersion = "0.0.529"
const GoextVersionTimestamp = "2024-10-07T17:20:40+0200"
const GoextVersionTimestamp = "2024-10-08T19:22:17+0200"