use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("Database error: {0}")]
Db(#[from] sea_orm::DbErr),
#[error("Unsupported database backend")]
UnsupportedBackend,
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("Deployment {id} cannot be promoted: status is not ready")]
NotReady {
id: i64,
},
#[error("Deployment {id} cannot be promoted: artifact has been deleted")]
ArtifactDeleted {
id: i64,
},
#[error("No previous deployment to roll back to for owner_key '{owner_key}'")]
NoPreviousDeployment {
owner_key: String,
},
#[error("Deployment {id} not found")]
NotFound {
id: i64,
},
#[error("Storage error: {0}")]
Storage(#[from] ferro_storage::Error),
#[error("{0}")]
Custom(String),
}
impl Error {
pub fn custom(message: impl Into<String>) -> Self {
Self::Custom(message.into())
}
}
impl From<String> for Error {
fn from(s: String) -> Self {
Self::Custom(s)
}
}
impl From<&str> for Error {
fn from(s: &str) -> Self {
Self::Custom(s.to_string())
}
}