瀏覽代碼

Improves errors.ByType() implementation

Manu Mtz-Almeida 10 年之前
父節點
當前提交
7e7004a224
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      errors.go

+ 4 - 1
errors.go

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