Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
c571f3f888
|
|||
e884ba6b89
|
|||
1a8e31e5ef
|
|||
eccc0fe9e5
|
|||
c8dec24a0d
|
@@ -167,7 +167,10 @@ func (id {{.Name}}) Valid() error {
|
|||||||
return validateID(prefix{{.Name}}, string(id))
|
return validateID(prefix{{.Name}}, string(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i {{.Name}}) String() string {
|
func (i *{{.Name}}) String() string {
|
||||||
|
if i == nil {
|
||||||
|
return "<nil>"
|
||||||
|
}
|
||||||
return string(i)
|
return string(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,7 +69,10 @@ func (e {{.EnumTypeName}}) ValuesMeta() []enums.EnumMetaValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{if $hasStr}}
|
{{if $hasStr}}
|
||||||
func (e {{.EnumTypeName}}) String() string {
|
func (e *{{.EnumTypeName}}) String() string {
|
||||||
|
if i == nil {
|
||||||
|
return "<nil>"
|
||||||
|
}
|
||||||
return string(e)
|
return string(e)
|
||||||
}
|
}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@@ -21,7 +21,10 @@ func (i {{.Name}}) MarshalBSONValue() (bsontype.Type, []byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i {{.Name}}) String() string {
|
func (i *{{.Name}}) String() string {
|
||||||
|
if i == nil {
|
||||||
|
return "<nil>"
|
||||||
|
}
|
||||||
return string(i)
|
return string(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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.RecoveredObj())},
|
||||||
|
"panic_type": {DataType: MDTString, Value: fmt.Sprintf("%T", verr.RecoveredObj())},
|
||||||
|
"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.RecoveredObj())},
|
||||||
|
"panic_type": {DataType: MDTString, Value: fmt.Sprintf("%T", verr.RecoveredObj())},
|
||||||
|
"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 {
|
||||||
|
6
go.mod
6
go.mod
@@ -22,11 +22,11 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bytedance/sonic v1.12.3 // indirect
|
github.com/bytedance/sonic v1.12.3 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.2.0 // indirect
|
github.com/bytedance/sonic/loader v0.2.1 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
@@ -35,7 +35,7 @@ require (
|
|||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/uuid v1.5.0 // indirect
|
github.com/google/uuid v1.5.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.10 // indirect
|
github.com/klauspost/compress v1.17.11 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
6
go.sum
6
go.sum
@@ -6,6 +6,8 @@ github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKz
|
|||||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM=
|
github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM=
|
||||||
github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
|
github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E=
|
||||||
|
github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||||
@@ -20,6 +22,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
|||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
|
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
|
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||||
@@ -57,6 +61,8 @@ github.com/jung-kurt/gofpdf v1.16.2 h1:jgbatWHfRlPYiK85qgevsZTHviWXKwB1TTiKdz5Pt
|
|||||||
github.com/jung-kurt/gofpdf v1.16.2/go.mod h1:1hl7y57EsiPAkLbOwzpzqgx1A30nQCk/YmFV8S2vmK0=
|
github.com/jung-kurt/gofpdf v1.16.2/go.mod h1:1hl7y57EsiPAkLbOwzpzqgx1A30nQCk/YmFV8S2vmK0=
|
||||||
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
|
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
|
||||||
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||||
|
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||||
|
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.528"
|
const GoextVersion = "0.0.533"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-10-07T17:20:40+0200"
|
const GoextVersionTimestamp = "2024-10-22T09:36:40+0200"
|
||||||
|
@@ -11,7 +11,7 @@ func (p PanicWrappedErr) Error() string {
|
|||||||
return "A panic occured"
|
return "A panic occured"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p PanicWrappedErr) ReoveredObj() any {
|
func (p PanicWrappedErr) RecoveredObj() any {
|
||||||
return p.panic
|
return p.panic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user