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)
| 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. |
| 298 | func 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 | } |
no test coverage detected