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)
| 107 | // Value: 5 |
| 108 | // }) |
| 109 | func (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. |