ByType returns a readonly copy filtered the byte. ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic.
(typ ErrorType)
| 96 | // ByType returns a readonly copy filtered the byte. |
| 97 | // ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic. |
| 98 | func (a errorMsgs) ByType(typ ErrorType) errorMsgs { |
| 99 | if len(a) == 0 { |
| 100 | return nil |
| 101 | } |
| 102 | if typ == ErrorTypeAny { |
| 103 | return a |
| 104 | } |
| 105 | var result errorMsgs |
| 106 | for _, msg := range a { |
| 107 | if msg.IsType(typ) { |
| 108 | result = append(result, msg) |
| 109 | } |
| 110 | } |
| 111 | return result |
| 112 | } |
| 113 | |
| 114 | // Last returns the last error in the slice. It returns nil if the array is empty. |
| 115 | // Shortcut for errors[len(errors)-1]. |