What a handler returns to answer with a status instead of a value. A handler's .{} means
no error. The server sends it as an RFC 9457 application/problem+json document:
find_user :: (id: int) -> string, Http_Error {
return "", not_found("No user with id %", id);
}
_, error := find_user(7);
// Sent as 404 {"type":"about:blank","title":"Not Found","status":404,"detail":"No user with id 7"}
assert(error.kind == .STATUS);
assert(error.status == 404);
assert(error.detail == "No user with id 7");Doesn't run in the browser (skipped on wasm).
app.on_error changes the format for all of them.
Fields
- kind: Http_Error_Kind
- status: int
- the HTTP status
- title: string
- short and fixed per status; the reason phrase when empty
- detail: string
- what happened this time
- problem_type: string
- a URI naming the kind of problem; "about:blank" when empty
- location: string
- for bad input:
body,query,path,headerorform - field: string
- for bad input: the parameter, header or JSON path that was wrong
- headers: [] Header_Field
- sent with the error (
Retry-After,WWW-Authenticate); see with_header