Adds IsType() helper

This commit is contained in:
Manu Mtz-Almeida 2015-06-12 21:33:16 +02:00
parent 00b279c66b
commit c0383dff6b
1 changed files with 4 additions and 0 deletions

View File

@ -76,6 +76,10 @@ func (msg *Error) Error() string {
return msg.Err.Error() return msg.Err.Error()
} }
func (msg *Error) IsType(flags ErrorType) bool {
return (msg.Type & flags) > 0
}
// Returns a readonly copy filterd the byte. // Returns a readonly copy filterd 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 {