Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors

Admin handlers return Result<_, laterite_admin::AdminError>.

VariantStatusPage
NotFound404Not found
Forbidden403Forbidden
Internal(_)500Something went wrong

Map a domain error

async fn edit(state: &AdminState, id: &str) -> Result<Response, AdminError> {
    let row = fetch(state, id)
        .await?                        // CoreError::NotFound -> 404, DB error -> 500
        .ok_or(AdminError::NotFound)?; // a missing row -> 404
    Ok(render(view(row)))
}
FromTo
CoreError::NotFound404
CoreError::Forbidden, CoreError::Unauthorized403
AuthErrorThrough CoreError, the same mapping
A database error, a render failure, a panic500

An unmatched admin URL renders the 404 page.

Show the cause in development

[app]
debug = true   # off by default

A 500 logs its cause through tracing::error! in every mode. With debug on, the page shows it too.

Validation

A refused submission is not an AdminError: it answers 422 with the form re-rendered. See Validation.