1pub use boatramp_types::error::ConfigError;
6
7#[derive(Debug, thiserror::Error)]
9pub enum StorageError {
10 #[error("object not found: {0}")]
12 NotFound(String),
13
14 #[error("invalid key: {0}")]
16 InvalidKey(String),
17
18 #[error("unsupported operation: {0}")]
20 Unsupported(String),
21
22 #[error("i/o error: {0}")]
24 Io(#[from] std::io::Error),
25
26 #[error("backend error: {0}")]
28 Backend(String),
29}
30
31impl StorageError {
32 pub fn unsupported(msg: impl Into<String>) -> Self {
34 Self::Unsupported(msg.into())
35 }
36
37 pub fn backend(msg: impl Into<String>) -> Self {
39 Self::Backend(msg.into())
40 }
41}
42
43#[derive(Debug, thiserror::Error)]
45pub enum KvError {
46 #[error("kv i/o error: {0}")]
48 Io(#[from] std::io::Error),
49
50 #[error("kv backend error: {0}")]
52 Backend(String),
53}
54
55impl KvError {
56 pub fn backend(msg: impl Into<String>) -> Self {
58 Self::Backend(msg.into())
59 }
60}
61
62#[derive(Debug, thiserror::Error)]
64pub enum DeployError {
65 #[error(transparent)]
67 Storage(#[from] StorageError),
68
69 #[error(transparent)]
71 Kv(#[from] KvError),
72
73 #[error("manifest serialization error: {0}")]
75 Serde(String),
76
77 #[error("not found: {0}")]
79 NotFound(String),
80
81 #[error("blob hash mismatch: expected {expected}, got {actual}")]
83 HashMismatch {
84 expected: String,
86 actual: String,
88 },
89
90 #[error("deployment incomplete: {} blob(s) still missing", .0.len())]
92 Incomplete(Vec<String>),
93
94 #[error("ambiguous deployment id prefix: {0}")]
96 Ambiguous(String),
97
98 #[error("conflict: {0}")]
102 Conflict(String),
103}
104
105impl From<serde_json::Error> for DeployError {
106 fn from(err: serde_json::Error) -> Self {
107 Self::Serde(err.to_string())
108 }
109}
110
111impl From<ConfigError> for DeployError {
112 fn from(err: ConfigError) -> Self {
113 Self::Serde(err.to_string())
114 }
115}