Improves errors.ByType() implementation

This commit is contained in:
Manu Mtz-Almeida 2015-06-12 21:34:06 +02:00
parent c0383dff6b
commit 7e7004a224
1 changed files with 4 additions and 1 deletions

View File

@ -86,9 +86,12 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
if len(a) == 0 { if len(a) == 0 {
return nil return nil
} }
if typ == ErrorTypeAny {
return a
}
var result errorMsgs = nil var result errorMsgs = nil
for _, msg := range a { for _, msg := range a {
if msg.Type&typ > 0 { if msg.IsType(typ) {
result = append(result, msg) result = append(result, msg)
} }
} }