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#[derive(Debug, Error)]
8pub enum DbError {
9 /// Connection failed. The URL stored here is always credential-redacted.
10 #[error("database connection failed (url: {url}): {source}")]
11 Connection {
12 url: String,
13 #[source]
14 source: sqlx::Error,
15 },
16
17 /// Migration failed.
18 #[error("database migration failed: {0}")]
19 Migration(#[from] sqlx::migrate::MigrateError),
20
21 /// I/O error (e.g., creating parent directories for `SQLite` file).
22 #[error("database I/O error: {0}")]
23 Io(#[from] std::io::Error),
24
25 /// Generic sqlx error not covered by the above variants.
26 #[error("database error: {0}")]
27 Sqlx(#[from] sqlx::Error),
28}