Skip to main content

Module error

Module error 

Source
Expand description

The page layer’s error type.

Deliberately not AdminError, for the same reason AdminError is not acme_proxy_core::error::Problem: its IntoResponse is hardcoded to application/json, and a browser navigating to /ui/accounts without a session must land on the sign-in page, not on a JSON document.

§Why the shape is chosen at construction

There are two kinds of caller and they need two different answers to a 401:

  • a browser following a link wants 303 See Other and a Location;
  • an htmx request wants an HX-Redirect header, which makes htmx do a real navigation rather than swapping the sign-in page into a <div>.

A 303 cannot serve both: fetch follows a redirect transparently, so htmx would only ever see the final response’s headers and would swap the sign-in page’s markup wherever the click came from. The page extractors have parts.headers in hand and read HX-Request there, which is why the decision lives at construction rather than in into_response.

§Why it renders no template

The error document is a const with two holes, not a minijinja render. An error path that can itself fail is not an error path — the same reasoning that keeps AdminError’s body a serde_json::json! literal.

Enums§

PageError
A failed page request.

Constants§

LOGIN_PATH
Where an unauthenticated request is sent.