MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / writeRawError

Function writeRawError

internal/httpapi/attachments.go:298–307  ·  view source on GitHub ↗

writeRawError writes the e2a error envelope as JSON to a raw (non-Huma) ResponseWriter, stamping the request id like the Huma handler path. Used by the raw attachment-download route, which can't return through Huma.

(w http.ResponseWriter, r *http.Request, status int, code, msg string, details map[string]any)

Source from the content-addressed store, hash-verified

296// ResponseWriter, stamping the request id like the Huma handler path. Used by the
297// raw attachment-download route, which can't return through Huma.
298func writeRawError(w http.ResponseWriter, r *http.Request, status int, code, msg string, details map[string]any) {
299 env := NewError(status, code, msg)
300 if details != nil {
301 env = env.WithDetails(details)
302 }
303 env.Err.RequestID = RequestIDFromContext(r.Context())
304 w.Header().Set("Content-Type", "application/json")
305 w.WriteHeader(status)
306 _ = json.NewEncoder(w).Encode(env)
307}

Callers 1

Calls 4

NewErrorFunction · 0.85
RequestIDFromContextFunction · 0.85
WithDetailsMethod · 0.80
WriteHeaderMethod · 0.45

Tested by

no test coverage detected