v0.0.193
This commit is contained in:
32
exerr/gin.go
32
exerr/gin.go
@@ -7,43 +7,43 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (ee *ExErr) toJson() gin.H {
|
||||
json := gin.H{}
|
||||
func (ee *ExErr) toJson(depth int) gin.H {
|
||||
ginJson := gin.H{}
|
||||
|
||||
if ee.UniqueID != "" {
|
||||
json["id"] = ee.UniqueID
|
||||
ginJson["id"] = ee.UniqueID
|
||||
}
|
||||
if ee.Category != CatWrap {
|
||||
json["category"] = ee.Category
|
||||
ginJson["category"] = ee.Category
|
||||
}
|
||||
if ee.Type != TypeWrap {
|
||||
json["type"] = ee.Type
|
||||
ginJson["type"] = ee.Type
|
||||
}
|
||||
if ee.StatusCode != nil {
|
||||
json["statuscode"] = ee.StatusCode
|
||||
ginJson["statuscode"] = ee.StatusCode
|
||||
}
|
||||
if ee.Message != "" {
|
||||
json["message"] = ee.Message
|
||||
ginJson["message"] = ee.Message
|
||||
}
|
||||
if ee.Caller != "" {
|
||||
json["caller"] = ee.Caller
|
||||
ginJson["caller"] = ee.Caller
|
||||
}
|
||||
if ee.Severity != SevErr {
|
||||
json["severity"] = ee.Severity
|
||||
ginJson["severity"] = ee.Severity
|
||||
}
|
||||
if ee.Timestamp != (time.Time{}) {
|
||||
json["time"] = ee.Timestamp.Format(time.RFC3339)
|
||||
ginJson["time"] = ee.Timestamp.Format(time.RFC3339)
|
||||
}
|
||||
if ee.WrappedErrType != "" {
|
||||
json["wrappedErrType"] = ee.WrappedErrType
|
||||
ginJson["wrappedErrType"] = ee.WrappedErrType
|
||||
}
|
||||
if ee.OriginalError != nil {
|
||||
json["original"] = ee.OriginalError.toJson()
|
||||
ginJson["original"] = ee.OriginalError.toJson(depth + 1)
|
||||
}
|
||||
|
||||
pkgconfig.ExtendGinDataOutput(json)
|
||||
pkgconfig.ExtendGinDataOutput(ee, depth, ginJson)
|
||||
|
||||
return json
|
||||
return ginJson
|
||||
}
|
||||
|
||||
func (ee *ExErr) Output(g *gin.Context) {
|
||||
@@ -75,10 +75,10 @@ func (ee *ExErr) Output(g *gin.Context) {
|
||||
}
|
||||
|
||||
if pkgconfig.ExtendedGinOutput {
|
||||
ginOutput["__data"] = ee.toJson()
|
||||
ginOutput["__data"] = ee.toJson(0)
|
||||
}
|
||||
|
||||
pkgconfig.ExtendGinOutput(ginOutput)
|
||||
pkgconfig.ExtendGinOutput(ee, ginOutput)
|
||||
|
||||
g.Render(statuscode, json.GoJsonRender{Data: ginOutput, NilSafeSlices: true, NilSafeMaps: true})
|
||||
}
|
||||
|
Reference in New Issue
Block a user