|
@@ -69,7 +69,7 @@ func (msg *Error) MarshalJSON() ([]byte, error) {
|
|
|
return json.Marshal(msg.JSON())
|
|
return json.Marshal(msg.JSON())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Implements the error interface
|
|
|
|
|
|
|
+// Error implements the error interface
|
|
|
func (msg Error) Error() string {
|
|
func (msg Error) Error() string {
|
|
|
return msg.Err.Error()
|
|
return msg.Err.Error()
|
|
|
}
|
|
}
|
|
@@ -78,7 +78,7 @@ func (msg *Error) IsType(flags ErrorType) bool {
|
|
|
return (msg.Type & flags) > 0
|
|
return (msg.Type & flags) > 0
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Returns a readonly copy filtered the byte.
|
|
|
|
|
|
|
+// ByType returns a readonly copy filtered the byte.
|
|
|
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic
|
|
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic
|
|
|
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
|
|
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
|
|
|
if len(a) == 0 {
|
|
if len(a) == 0 {
|
|
@@ -96,17 +96,16 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
|
|
|
return result
|
|
return result
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Returns the last error in the slice. It returns nil if the array is empty.
|
|
|
|
|
|
|
+// Last returns the last error in the slice. It returns nil if the array is empty.
|
|
|
// Shortcut for errors[len(errors)-1]
|
|
// Shortcut for errors[len(errors)-1]
|
|
|
func (a errorMsgs) Last() *Error {
|
|
func (a errorMsgs) Last() *Error {
|
|
|
- length := len(a)
|
|
|
|
|
- if length > 0 {
|
|
|
|
|
|
|
+ if length := len(a); length > 0 {
|
|
|
return a[length-1]
|
|
return a[length-1]
|
|
|
}
|
|
}
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Returns an array will all the error messages.
|
|
|
|
|
|
|
+// Errors returns an array will all the error messages.
|
|
|
// Example:
|
|
// Example:
|
|
|
// c.Error(errors.New("first"))
|
|
// c.Error(errors.New("first"))
|
|
|
// c.Error(errors.New("second"))
|
|
// c.Error(errors.New("second"))
|