From 65ec318e9d381a43d7d6360403d295411cbfab0c Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sun, 30 May 2021 23:27:18 +0300 Subject: [PATCH] chore: add errors for managers --- migra/src/error.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/migra/src/error.rs b/migra/src/error.rs index 11f86ab..437833f 100644 --- a/migra/src/error.rs +++ b/migra/src/error.rs @@ -5,12 +5,32 @@ pub type MigraResult = Result; #[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), } }