pub use boatramp_types::error::ConfigError;
#[derive(Debug, thiserror::Error)]
pub enum StorageError {
#[error("object not found: {0}")]
NotFound(String),
#[error("invalid key: {0}")]
InvalidKey(String),
#[error("unsupported operation: {0}")]
Unsupported(String),
#[error("i/o error: {0}")]
Io(#[from] std::io::Error),
#[error("backend error: {0}")]
Backend(String),
}
impl StorageError {
pub fn unsupported(msg: impl Into<String>) -> Self {
Self::Unsupported(msg.into())
}
pub fn backend(msg: impl Into<String>) -> Self {
Self::Backend(msg.into())
}
}
#[derive(Debug, thiserror::Error)]
pub enum KvError {
#[error("kv i/o error: {0}")]
Io(#[from] std::io::Error),
#[error("kv backend error: {0}")]
Backend(String),
}
impl KvError {
pub fn backend(msg: impl Into<String>) -> Self {
Self::Backend(msg.into())
}
}
#[derive(Debug, thiserror::Error)]
pub enum DeployError {
#[error(transparent)]
Storage(#[from] StorageError),
#[error(transparent)]
Kv(#[from] KvError),
#[error("manifest serialization error: {0}")]
Serde(String),
#[error("not found: {0}")]
NotFound(String),
#[error("blob hash mismatch: expected {expected}, got {actual}")]
HashMismatch {
expected: String,
actual: String,
},
#[error("deployment incomplete: {} blob(s) still missing", .0.len())]
Incomplete(Vec<String>),
#[error("ambiguous deployment id prefix: {0}")]
Ambiguous(String),
#[error("conflict: {0}")]
Conflict(String),
}
impl From<serde_json::Error> for DeployError {
fn from(err: serde_json::Error) -> Self {
Self::Serde(err.to_string())
}
}
impl From<ConfigError> for DeployError {
fn from(err: ConfigError) -> Self {
Self::Serde(err.to_string())
}
}