chore: add errors for managers
This commit is contained in:
parent
5a4a3c8eb0
commit
65ec318e9d
1 changed files with 20 additions and 0 deletions
|
@ -5,12 +5,32 @@ pub type MigraResult<T> = Result<T, Error>;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
FailedOpenTransaction,
|
||||
FailedCommitTransaction,
|
||||
FailedRollbackTransaction,
|
||||
|
||||
FailedCreateMigrationsTable,
|
||||
FailedApplySql,
|
||||
FailedInsertMigration,
|
||||
FailedDeleteMigration,
|
||||
FailedGetAppliedMigrations,
|
||||
|
||||
Io(io::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::FailedOpenTransaction => fmt.write_str("Failed to open a transaction"),
|
||||
Error::FailedCommitTransaction => fmt.write_str("Failed to commit a transaction"),
|
||||
Error::FailedRollbackTransaction => fmt.write_str("Failed to rollback a transaction"),
|
||||
Error::FailedCreateMigrationsTable => {
|
||||
fmt.write_str("Failed to create a migrations table")
|
||||
}
|
||||
Error::FailedApplySql => fmt.write_str("Failed to apply sql"),
|
||||
Error::FailedInsertMigration => fmt.write_str("Failed to insert a migration"),
|
||||
Error::FailedDeleteMigration => fmt.write_str("Failed to delete a migration"),
|
||||
Error::FailedGetAppliedMigrations => fmt.write_str("Failed to get applied migrations"),
|
||||
Error::Io(ref error) => write!(fmt, "{}", error),
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue