Better migration error message

This commit is contained in:
Antoine Gersant 2024-07-13 18:28:51 -07:00
parent 0e63f64513
commit 1020f27413
2 changed files with 4 additions and 4 deletions
src

View file

@ -17,8 +17,8 @@ pub enum Error {
ConnectionPool,
#[error("Filesystem error for `{0}`: `{1}`")]
Io(PathBuf, std::io::Error),
#[error("Could not apply database migrations")]
Migration,
#[error("Could not apply database migrations: {0}")]
Migration(sqlx::migrate::MigrateError),
}
#[derive(Clone)]
@ -53,7 +53,7 @@ impl DB {
.run(&self.pool)
.await
.and(Ok(()))
.or(Err(Error::Migration))
.map_err(Error::Migration)
}
}

View file

@ -173,7 +173,7 @@ impl From<db::Error> for APIError {
db::Error::ConnectionPoolBuild => APIError::Internal,
db::Error::ConnectionPool => APIError::Internal,
db::Error::Io(p, e) => APIError::Io(p, e),
db::Error::Migration => APIError::Internal,
db::Error::Migration(_) => APIError::Internal,
}
}
}