Liking cljdoc? Tell your friends :D

dev.arkaitz.web-base.error

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.
raw docstring

default-handlerclj

(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.
sourceraw docstring

fragmentclj

(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.
sourceraw docstring

middlewareclj

(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.
sourceraw docstring

rendererclj

(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.
sourceraw docstring

throw!clj

(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.
sourceraw docstring

varyclj

Error responses vary on the htmx headers and on Accept.

Error responses vary on the htmx headers and on `Accept`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close