|
|
@@ -28,11 +28,11 @@ func ErrorLogger() HandlerFunc {
|
|
|
func ErrorLoggerT(typ ErrorType) HandlerFunc {
|
|
|
return func(c *Context) {
|
|
|
c.Next()
|
|
|
-
|
|
|
+ // avoid writting if we already wrote into the response body
|
|
|
if !c.Writer.Written() {
|
|
|
- json := c.Errors.ByType(typ).JSON()
|
|
|
- if json != nil {
|
|
|
- c.JSON(-1, json)
|
|
|
+ errors := c.Errors.ByType(typ)
|
|
|
+ if len(errors) > 0 {
|
|
|
+ c.JSON(-1, errors)
|
|
|
}
|
|
|
}
|
|
|
}
|