MCPcopy
hub / github.com/gin-gonic/gin / ByType

Method ByType

errors.go:98–112  ·  view source on GitHub ↗

ByType returns a readonly copy filtered the byte. ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic.

(typ ErrorType)

Source from the content-addressed store, hash-verified

96// ByType returns a readonly copy filtered the byte.
97// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic.
98func (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].

Callers 5

TestErrorSliceFunction · 0.95
TestContextResetFunction · 0.80
TestContextTypedErrorFunction · 0.80
ErrorLoggerTFunction · 0.80
LoggerWithConfigFunction · 0.80

Calls 1

IsTypeMethod · 0.80

Tested by 3

TestErrorSliceFunction · 0.76
TestContextResetFunction · 0.64
TestContextTypedErrorFunction · 0.64