Errors as data with three renderings (SPEC §9): a full page, a fragment for
an htmx swap, or plain text when the client does not accept HTML. A datum is
{:status n} plus optional :title and :detail strings; a coercion
failure adds :wb/coercion, the humanized explanation as data. The base's
own datums carry a status and structured data, never prose — it knows no
language (SPEC §14); words come from the host's :error-layout, which
receives the request and with it whatever the host put there.
The default error page is self-contained on purpose: a layout that just threw must not be asked to render its own failure.
Errors as data with three renderings (SPEC §9): a full page, a fragment for
an htmx swap, or plain text when the client does not accept HTML. A datum is
`{:status n}` plus optional `:title` and `:detail` strings; a coercion
failure adds `:wb/coercion`, the humanized explanation as data. The base's
own datums carry a status and structured data, never prose — it knows no
language (SPEC §14); words come from the host's `:error-layout`, which
receives the request and with it whatever the host put there.
The default error page is self-contained on purpose: a layout that just
threw must not be asked to render its own failure.(default-handler render-error)The handler behind the router: 404 for no route, 405 with Allow for a
route without the method, and 500 — logged — when the matched handler
answered nil, which is a programming error, not content negotiation.
Router middleware never runs here, so it renders on its own.
The handler behind the router: 404 for no route, 405 with `Allow` for a route without the method, and 500 — logged — when the matched handler answered nil, which is a programming error, not content negotiation. Router middleware never runs here, so it renders on its own.
(fragment {:keys [status title detail]})The htmx rendering: what lands inside the target. data-status carries the
status for the host's CSS and scripts.
The htmx rendering: what lands inside the target. `data-status` carries the status for the host's CSS and scripts.
(middleware render-error)reitit middleware that turns any throw into a rendered error. Unexpected throwables are logged with their stack trace and answered with a bare 500: the message never reaches the client.
reitit middleware that turns any throw into a rendered error. Unexpected throwables are logged with their stack trace and answered with a bare 500: the message never reaches the client.
(renderer {:keys [error-layout]})Returns (fn [datum request] response). :error-layout, when given, is a
layout like any other — a function of a slot map — and receives :content
(the fragment), :request and :error (the datum); it is used only for the
page rendering.
Returns `(fn [datum request] response)`. `:error-layout`, when given, is a layout like any other — a function of a slot map — and receives `:content` (the fragment), `:request` and `:error` (the datum); it is used only for the page rendering.
(throw! datum)Throws datum as an exception the middleware turns back into a rendered
error. For a handler that already holds the datum, returning the rendered
response is the shorter path; this is for code deeper down.
Throws `datum` as an exception the middleware turns back into a rendered error. For a handler that already holds the datum, returning the rendered response is the shorter path; this is for code deeper down.
Error responses vary on the htmx headers and on Accept.
Error responses vary on the htmx headers and on `Accept`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |