Skip to main content

Module error

Module error 

Source
Expand description

HTTP-facing error type for the logdive-api server.

Classifies errors into three HTTP-shaped buckets:

  • AppError::BadRequest — the client sent something malformed (missing q, unparseable query expression, bad datetime).
  • AppError::NotFound — an explicit miss by an endpoint, reserved for future endpoints that look up specific records. Not used for route-level misses; Axum handles unknown-route 404s on its own.
  • AppError::Internal — any failure below the request boundary (SQLite error, corrupt JSON in the index, I/O failure). These are logged in full to tracing but shown to the client only as a generic "internal server error" message.

The status-code mapping lives in exactly one place: the From<LogdiveError> impl. Handlers can therefore use ? on any LogdiveError-returning operation and get correct classification for free.

For source types that are not LogdiveError but whose LogdiveError conversion is already defined in core (e.g. QueryParseError via its #[from] variant on LogdiveError::QueryParse), this module provides an explicit shim From impl. Rust’s ? operator only performs a single From conversion, so Result<T, QueryParseError> -> Result<T, AppError> needs its own direct impl rather than going through LogdiveError implicitly.

Enums§

AppError
HTTP error surface used across all handlers.