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

Function WriteErr

error.go:258–272  ·  view source on GitHub ↗

WriteErr writes an error response with the given context, using the configured error type and with the given status code and message. It is marshaled using the API's content negotiation methods.

(api API, ctx Context, status int, msg string, errs ...error)

Source from the content-addressed store, hash-verified

256// configured error type and with the given status code and message. It is
257// marshaled using the API's content negotiation methods.
258func WriteErr(api API, ctx Context, status int, msg string, errs ...error) error {
259 var err = NewErrorWithContext(ctx, status, msg, errs...)
260
261 // NewError may have modified the status code, so update it here if needed.
262 // If it was not modified, then this is a no-op.
263 status = err.GetStatus()
264
265 writtenErr := writeResponse(api, ctx, status, "", err)
266 if writtenErr != nil {
267 // If we can't write the error, log it so we know what happened.
268 fmt.Fprintf(os.Stderr, "could not write error: %v\n", writtenErr)
269 }
270
271 return writtenErr
272}
273
274// Status304NotModified returns a 304. This is not really an error, but
275// provides a way to send non-default responses.

Callers 2

RegisterFunction · 0.85
writeErrFunction · 0.85

Calls 2

writeResponseFunction · 0.85
GetStatusMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…