Skip to main content

gwk_kernel/
error.rs

1//! What can go wrong.
2//!
3//! Every variant here is a STARTUP or INITIALIZATION failure — nothing in this
4//! crate answers a request yet, so nothing maps to `gwk_domain::KernelErrorCode`.
5//! That mapping arrives with the request path, not before it.
6
7/// A kernel failure.
8#[derive(Debug, thiserror::Error)]
9pub enum KernelError {
10    /// A required environment variable is missing, malformed, or forbidden in
11    /// this process.
12    #[error("configuration: {0}")]
13    Config(String),
14
15    /// The target database is not one this binary may initialize or serve.
16    #[error("schema: {0}")]
17    Schema(String),
18
19    /// The credential holds privileges the kernel refuses to run with, or
20    /// lacks ones it needs.
21    #[error("privilege: {0}")]
22    Privilege(String),
23
24    /// This process does not hold write authority for the store.
25    #[error("writer: {0}")]
26    Writer(String),
27
28    #[error("database: {0}")]
29    Database(#[from] sqlx::Error),
30}
31
32pub type Result<T> = std::result::Result<T, KernelError>;