lib_migrations_core/
error.rs1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[error("Migration {version} failed: {message}")]
8 MigrationFailed { version: u64, message: String },
9
10 #[error("Migration {0} does not support rollback")]
11 RollbackNotSupported(u64),
12
13 #[error("Invalid migration order: {0}")]
14 InvalidOrder(String),
15
16 #[error("Store error: {0}")]
17 Store(String),
18
19 #[error("Migration {0} not found")]
20 NotFound(u64),
21
22 #[error("Migration {0} already applied")]
23 AlreadyApplied(u64),
24}
25
26impl Error {
27 pub fn store(msg: impl Into<String>) -> Self {
28 Self::Store(msg.into())
29 }
30
31 pub fn failed(version: u64, msg: impl Into<String>) -> Self {
32 Self::MigrationFailed {
33 version,
34 message: msg.into(),
35 }
36 }
37}