Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
eccc0fe9e5
|
|||
c8dec24a0d
|
|||
b8cb989e54
|
@@ -19,6 +19,52 @@ func FromError(err error) *ExErr {
|
|||||||
return verr
|
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)
|
// A foreign error (eg a MongoDB exception)
|
||||||
return &ExErr{
|
return &ExErr{
|
||||||
UniqueID: newID(),
|
UniqueID: newID(),
|
||||||
|
@@ -48,6 +48,12 @@ func (ee *ExErr) toJson(depth int, applyExtendListener bool, outputMeta bool) la
|
|||||||
metaJson[metaKey] = metaVal.rawValueForJson()
|
metaJson[metaKey] = metaVal.rawValueForJson()
|
||||||
}
|
}
|
||||||
ginJson["meta"] = metaJson
|
ginJson["meta"] = metaJson
|
||||||
|
|
||||||
|
extraJson := langext.H{}
|
||||||
|
for extraKey, extraVal := range ee.Extra {
|
||||||
|
extraJson[extraKey] = extraVal
|
||||||
|
}
|
||||||
|
ginJson["extra"] = extraJson
|
||||||
}
|
}
|
||||||
|
|
||||||
if applyExtendListener {
|
if applyExtendListener {
|
||||||
|
@@ -111,3 +111,16 @@ func OriginalError(e error) error {
|
|||||||
|
|
||||||
return bmerr
|
return bmerr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UniqueID(v error) *string {
|
||||||
|
if v == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//goland:noinspection GoTypeAssertionOnErrors
|
||||||
|
if verr, ok := v.(*ExErr); ok {
|
||||||
|
return &verr.UniqueID
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.527"
|
const GoextVersion = "0.0.530"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-10-07T17:19:30+0200"
|
const GoextVersionTimestamp = "2024-10-09T11:15:26+0200"
|
||||||
|
Reference in New Issue
Block a user