Archived
1
0
Fork 0

chore: add errors for managers

This commit is contained in:
Dmitriy Pleshevskiy 2021-05-30 23:27:18 +03:00
parent 5a4a3c8eb0
commit 65ec318e9d

View file

@ -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),
}
}