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

Struct ErrorModel

error.go:70–92  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

68// },
69// }
70type 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.
95func (e *ErrorModel) Error() string {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected