MCPcopy
hub / github.com/danielgtaylor/huma / Add

Method Add

error.go:109–116  ·  view source on GitHub ↗

Add an error to the `Errors` slice. If passed a struct that satisfies the `huma.ErrorDetailer` interface, then it is used, otherwise the error string is used as the error detail message. err := &ErrorModel{ /* ... */ } err.Add(&huma.ErrorDetail{ Message: "expected boolean", Location: "body.fr

(err error)

Source from the content-addressed store, hash-verified

107// Value: 5
108// })
109func (e *ErrorModel) Add(err error) {
110 if converted, ok := err.(ErrorDetailer); ok {
111 e.Errors = append(e.Errors, converted.ErrorDetail())
112 return
113 }
114
115 e.Errors = append(e.Errors, &ErrorDetail{Message: err.Error()})
116}
117
118// GetStatus returns the HTTP status that should be returned to the client
119// for this error.

Callers 1

TestErrorFunction · 0.95

Calls 2

ErrorDetailMethod · 0.65
ErrorMethod · 0.65

Tested by 1

TestErrorFunction · 0.76