Skip to main content

zeph_db/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4use thiserror::Error;
5
6/// Unified database error type for `zeph-db`.
7#[non_exhaustive]
8#[derive(Debug, Error)]
9pub enum DbError {
10    /// Connection failed. The URL stored here is always credential-redacted.
11    #[error("database connection failed (url: {url}): {source}")]
12    Connection {
13        url: String,
14        #[source]
15        source: sqlx::Error,
16    },
17
18    /// Migration failed.
19    #[error("database migration failed: {0}")]
20    Migration(#[from] sqlx::migrate::MigrateError),
21
22    /// I/O error (e.g., creating parent directories for `SQLite` file).
23    #[error("database I/O error: {0}")]
24    Io(#[from] std::io::Error),
25
26    /// Generic sqlx error not covered by the above variants.
27    #[error("sqlx error: {0}")]
28    Sqlx(#[from] sqlx::Error),
29}