ErrorModel defines a basic error message model based on RFC 9457 Problem Details for HTTP APIs (https://datatracker.ietf.org/doc/html/rfc9457). It is augmented with an `errors` field of `huma.ErrorDetail` objects that can help provide exhaustive & descriptive errors. err := &huma.ErrorModel{ Tit
| 68 | // }, |
| 69 | // } |
| 70 | type ErrorModel struct { |
| 71 | // Type is a URI to get more information about the error type. |
| 72 | Type string `json:"type,omitempty" format:"uri" default:"about:blank" example:"https://example.com/errors/example" doc:"A URI reference to human-readable documentation for the error."` |
| 73 | |
| 74 | // Title provides a short static summary of the problem. Huma will default this |
| 75 | // to the HTTP response status code text if not present. |
| 76 | Title string `json:"title,omitempty" example:"Bad Request" doc:"A short, human-readable summary of the problem type. This value should not change between occurrences of the error."` |
| 77 | |
| 78 | // Status provides the HTTP status code for client convenience. Huma will |
| 79 | // default this to the response status code if unset. This SHOULD match the |
| 80 | // response status code (though proxies may modify the actual status code). |
| 81 | Status int `json:"status,omitempty" example:"400" doc:"HTTP status code"` |
| 82 | |
| 83 | // Detail is an explanation specific to this error occurrence. |
| 84 | Detail string `json:"detail,omitempty" example:"Property foo is required but is missing." doc:"A human-readable explanation specific to this occurrence of the problem."` |
| 85 | |
| 86 | // Instance is a URI to get more info about this error occurrence. |
| 87 | Instance string `json:"instance,omitempty" format:"uri" example:"https://example.com/error-log/abc123" doc:"A URI reference that identifies the specific occurrence of the problem."` |
| 88 | |
| 89 | // Errors provides an optional mechanism of passing additional error details |
| 90 | // as a list. |
| 91 | Errors []*ErrorDetail `json:"errors,omitempty" doc:"Optional list of individual error details"` |
| 92 | } |
| 93 | |
| 94 | // Error satisfies the `error` interface. It returns the error's detail field. |
| 95 | func (e *ErrorModel) Error() string { |
nothing calls this directly
no outgoing calls
no test coverage detected