Skip to main content

laterite_core/
error.rs

1//! The framework-level error taxonomy.
2//!
3//! Application crates layer their own domain errors on top; anything that
4//! crosses a framework boundary (handlers, modules, jobs) converges here so
5//! HTTP mapping and logging stay uniform.
6
7use thiserror::Error;
8
9#[derive(Debug, Error)]
10pub enum CoreError {
11    #[error("configuration error: {0}")]
12    Config(String),
13
14    #[error("database error")]
15    Database(#[from] sqlx::Error),
16
17    #[error("migration '{name}' in module '{module}' changed after being applied")]
18    MigrationDrift { module: String, name: String },
19
20    #[error("migration '{name}' in module '{module}' cannot be reversed")]
21    Irreversible { module: String, name: String },
22
23    #[error("not found: {0}")]
24    NotFound(String),
25
26    #[error("validation failed: {0}")]
27    Validation(String),
28
29    #[error("unauthorized")]
30    Unauthorized,
31
32    #[error("forbidden: {0}")]
33    Forbidden(String),
34
35    #[error("conflict: {0}")]
36    Conflict(String),
37
38    #[error("internal error: {0}")]
39    Internal(String),
40}
41
42pub type CoreResult<T> = Result<T, CoreError>;