Skip to main content

drizzle_cli/
error.rs

1//! Error types for the CLI
2
3use thiserror::Error;
4
5use crate::config::Error;
6
7/// CLI errors
8#[derive(Debug, Error)]
9pub enum CliError {
10    /// Configuration error
11    #[error("Configuration error: {0}")]
12    Config(#[from] Error),
13
14    /// I/O error
15    #[error("I/O error: {0}")]
16    IoError(String),
17
18    /// No schema files found
19    #[error("No schema files found matching: {0}")]
20    NoSchemaFiles(String),
21
22    /// Dialect mismatch between snapshots
23    #[error("Dialect mismatch between previous and current snapshots")]
24    DialectMismatch,
25
26    /// Database connection error
27    #[error("Database connection failed: {0}")]
28    ConnectionError(String),
29
30    /// Migration execution error
31    #[error("Migration failed: {0}")]
32    MigrationError(String),
33
34    /// Missing database driver
35    #[error("No driver available for {dialect}. Build with '{feature}' feature enabled.")]
36    MissingDriver {
37        dialect: &'static str,
38        feature: &'static str,
39    },
40
41    /// Operation not supported for this driver.
42    ///
43    /// Used for codegen-only drivers (e.g. `durable-sqlite` — no way to reach
44    /// a running DO from the CLI) and for remote drivers the CLI hasn't been
45    /// wired to yet (e.g. `d1-http`).
46    #[error("{operation} is not supported for driver '{driver}'. {hint}")]
47    UnsupportedForDriver {
48        operation: &'static str,
49        driver: &'static str,
50        hint: &'static str,
51    },
52
53    /// Other errors
54    #[error("{0}")]
55    Other(String),
56}