You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
API routes can answer with an HTML error page; AppError keeps two variants of everything #300
AppError has six page/API pairs: BadRequest/ApiBadRequest, RedirectToLogin/Unauthorized, RedirectToCourses/ApiNoCourse, PasswordChangeRequired/Api…, AiOff/ApiAiOff, NoPermission/ApiNoPermission. CurrentUser mirrors them with require_* and require_*_api. Extractors choose by path.starts_with("/api/"); handlers choose by hand.
NotFound, Db and Internal have no API form, so these answer a script with an HTML page: pages::save_note (POST /api/lessons/{slug}/note), tutor::session (GET /api/tutor/session), manage::save_keys, and any database error on any /api/* route.
Fix, one PR:into_response records the kind of error in a response extension. error::in_layout, which already works out whether the request is an API one, draws {"error": …} or the page. Then the six Api* variants and the _api methods go.
Related, same PR or the next:
API error text is mixed: 44 ApiBadRequest(crate::t(…)) against 23 English literals such as "implausible result" and "unknown lesson" (routes/sprint.rs, routes/guide.rs).
A refused form answers 200 (src/routes/profile.rs:501), 403 (two-factor), 422 (token and code forms) or a redirect with a notice (courses). prove_owner returns (StatusCode, String) and callers branch on the status to pick a message. A ProofRefused enum and one status for "show the form again".
From the code review of 24 November 2026. Line numbers are as of 0.5.0 (2547b36).
Activity