Skip to main content

toolu_orm_cli/migrate/
error.rs

1//! MigrateError enum for migration runner failures.
2
3use thiserror::Error;
4use toolu_orm_connection::DbError;
5
6#[derive(Debug, Error)]
7pub enum MigrateError {
8  #[error("database error: {0}")]
9  Database(String),
10
11  #[error("failed to read migrations directory: {0}")]
12  ReadDir(String),
13
14  #[error("failed to read migration file: {0}")]
15  ReadFile(String),
16
17  #[error("migration {file} has been modified (expected {expected}, got {actual})")]
18  HashMismatch {
19    file: String,
20    expected: String,
21    actual: String,
22  },
23}
24
25pub(crate) fn map_db(err: &DbError) -> MigrateError {
26  MigrateError::Database(err.to_string())
27}