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    /// Schema source failed to parse or used attributes the macros reject
23    #[error("Schema parse failed:\n  {0}")]
24    SchemaParse(String),
25
26    /// Dialect mismatch between snapshots
27    #[error("Dialect mismatch between previous and current snapshots")]
28    DialectMismatch,
29
30    /// Database connection error
31    #[error("Database connection failed: {0}")]
32    ConnectionError(String),
33
34    /// Migration execution error
35    #[error("Migration failed: {0}")]
36    MigrationError(String),
37
38    /// Missing database driver
39    #[error("No driver available for {dialect}. Build with '{feature}' feature enabled.")]
40    MissingDriver {
41        dialect: &'static str,
42        feature: &'static str,
43    },
44
45    /// Operation not supported for this driver.
46    ///
47    /// Used for codegen-only drivers (e.g. `durable-sqlite` — no way to reach
48    /// a running DO from the CLI) and for remote drivers the CLI hasn't been
49    /// wired to yet (e.g. `d1-http`).
50    #[error("{operation} is not supported for driver '{driver}'. {hint}")]
51    UnsupportedForDriver {
52        operation: &'static str,
53        driver: &'static str,
54        hint: &'static str,
55    },
56
57    /// Other errors
58    #[error("{0}")]
59    Other(String),
60}