use kiseki_common::error::{KisekiError, PermanentError};
use kiseki_common::ids::{CompositionId, NamespaceId, ShardId};
#[derive(Debug, thiserror::Error)]
pub enum CompositionError {
#[error("namespace not found: {0:?}")]
NamespaceNotFound(NamespaceId),
#[error("composition not found: {0:?}")]
CompositionNotFound(CompositionId),
#[error("cross-shard rename: source {0:?}, target {1:?}")]
CrossShardRename(ShardId, ShardId),
#[error("namespace is read-only: {0:?}")]
ReadOnlyNamespace(NamespaceId),
#[error("multipart upload not found: {0}")]
MultipartNotFound(String),
#[error("multipart not finalized: {0}")]
MultipartNotFinalized(String),
#[error("version not found: {0:?} v{1}")]
VersionNotFound(CompositionId, u64),
}
impl From<CompositionError> for KisekiError {
fn from(e: CompositionError) -> Self {
KisekiError::Permanent(PermanentError::InvariantViolation(e.to_string()))
}
}