Skip to main content

dpp_domain/catalog/
error.rs

1//! [`CatalogError`] — errors from runtime catalog registration.
2
3/// Errors from runtime catalog registration.
4#[derive(Debug, Clone, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum CatalogError {
7    /// A descriptor for this key already exists.
8    AlreadyExists(String),
9    /// `current_schema_version` is not a valid semver string.
10    InvalidSchemaVersion { key: String, version: String },
11    /// `current_schema_version` is not listed in `schema_versions`.
12    CurrentVersionNotListed { key: String, version: String },
13}
14
15impl std::fmt::Display for CatalogError {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            Self::AlreadyExists(key) => write!(f, "sector '{key}' already in catalog"),
19            Self::InvalidSchemaVersion { key, version } => write!(
20                f,
21                "sector '{key}' currentSchemaVersion '{version}' is not valid semver"
22            ),
23            Self::CurrentVersionNotListed { key, version } => write!(
24                f,
25                "sector '{key}' currentSchemaVersion '{version}' is not in its schemaVersions list"
26            ),
27        }
28    }
29}
30
31impl std::error::Error for CatalogError {}