ferro_deployments/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum Error {
8 #[error("Database error: {0}")]
10 Db(#[from] sea_orm::DbErr),
11
12 #[error("Unsupported database backend")]
14 UnsupportedBackend,
15
16 #[error("JSON error: {0}")]
18 Json(#[from] serde_json::Error),
19
20 #[error("Deployment {id} cannot be promoted: status is not ready")]
22 NotReady {
23 id: i64,
25 },
26
27 #[error("Deployment {id} cannot be promoted: artifact has been deleted")]
29 ArtifactDeleted {
30 id: i64,
32 },
33
34 #[error("No previous deployment to roll back to for owner_key '{owner_key}'")]
36 NoPreviousDeployment {
37 owner_key: String,
39 },
40
41 #[error("Deployment {id} not found")]
43 NotFound {
44 id: i64,
46 },
47
48 #[error("Storage error: {0}")]
50 Storage(#[from] ferro_storage::Error),
51
52 #[error("{0}")]
54 Custom(String),
55}
56
57impl Error {
58 pub fn custom(message: impl Into<String>) -> Self {
60 Self::Custom(message.into())
61 }
62}
63
64impl From<String> for Error {
65 fn from(s: String) -> Self {
66 Self::Custom(s)
67 }
68}
69
70impl From<&str> for Error {
71 fn from(s: &str) -> Self {
72 Self::Custom(s.to_string())
73 }
74}