Improves error management

This commit is contained in:
Manu Mtz-Almeida
2014-07-08 00:16:41 +02:00
parent b5ddd484de
commit 3295c6e9c4
2 changed files with 45 additions and 16 deletions

View File

@ -7,10 +7,15 @@ import (
)
func ErrorLogger() HandlerFunc {
return ErrorLoggerT(ErrorTypeAll)
}
func ErrorLoggerT(typ uint32) HandlerFunc {
return func(c *Context) {
c.Next()
if len(c.Errors) > 0 {
errs := c.Errors.ByType(typ)
if len(errs) > 0 {
// -1 status code = do not change current one
c.JSON(-1, c.Errors)
}