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

Method Errors

errors.go:130–139  ·  view source on GitHub ↗

Errors returns an array with all the error messages. Example: c.Error(errors.New("first")) c.Error(errors.New("second")) c.Error(errors.New("third")) c.Errors.Errors() // == []string{"first", "second", "third"}

()

Source from the content-addressed store, hash-verified

128// c.Error(errors.New("third"))
129// c.Errors.Errors() // == []string{"first", "second", "third"}
130func (a errorMsgs) Errors() []string {
131 if len(a) == 0 {
132 return nil
133 }
134 errorStrings := make([]string, len(a))
135 for i, err := range a {
136 errorStrings[i] = err.Error()
137 }
138 return errorStrings
139}
140
141func (a errorMsgs) JSON() any {
142 switch length := len(a); length {

Callers 3

TestErrorSliceFunction · 0.95
TestContextResetFunction · 0.80
TestContextTypedErrorFunction · 0.80

Calls 1

ErrorMethod · 0.45

Tested by 3

TestErrorSliceFunction · 0.76
TestContextResetFunction · 0.64
TestContextTypedErrorFunction · 0.64