use crate::algebra::AlgebraBuildError;
use crate::atlas::AtlasScoreError;
use crate::certificate::CertParseError;
use crate::ext::ExtError;
use crate::field::FieldError;
use crate::verify::VerifyError;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CatalogAtlasArtifactError {
ParseLimit {
path: String,
used: usize,
limit: usize,
},
Syntax { byte: usize, message: String },
Schema { found: String },
Kind { found: String },
Engine { found: String },
NonCanonical,
Certificate(CertParseError),
Verify(VerifyError),
Algebra(AlgebraBuildError),
FieldMismatch { certificate: u64, artifact: u64 },
Field(FieldError),
Provenance { found: String },
Catalog { message: String },
Atlas(crate::atlas::CatalogAtlasError),
Multiplicity(crate::atlas::MultiplicityError),
Score(AtlasScoreError),
Ext(ExtError),
CountMismatch { field: String },
ReplayMismatch { field: String },
VerificationLimit {
field: &'static str,
declared: usize,
limit: usize,
},
Overflow { field: &'static str },
}
display_error! { CatalogAtlasArtifactError {
Self::ParseLimit { path, used, limit } => "atlas artifact field {path} needs {used} units, limit {limit}";
Self::Syntax { byte, message } => "invalid atlas artifact JSON at byte {byte}: {message}";
Self::Schema { found } => "unsupported atlas artifact schema {found:?}";
Self::Kind { found } => "unsupported atlas artifact kind {found:?}";
Self::Engine { found } => "unsupported atlas artifact engine {found:?}";
Self::NonCanonical => "atlas artifact JSON is not canonical";
Self::Certificate(error) => "embedded completion certificate rejected: {error}";
Self::Verify(error) => "embedded completion certificate failed verification: {error}";
Self::Algebra(error) => "verified completion could not rebuild an algebra: {error}";
Self::FieldMismatch { certificate, artifact } => "certificate field F_{certificate} differs from artifact field F_{artifact}";
Self::Field(error) => "artifact field is invalid: {error}";
Self::Provenance { found } => "unsupported catalog provenance {found:?}";
Self::Catalog { message } => "catalog reconstruction failed: {message}";
Self::Atlas(error) => "catalog atlas replay failed: {error}";
Self::Multiplicity(error) => "multiplicity replay failed: {error}";
Self::Score(error) => "self-Ext score replay failed: {error}";
Self::Ext(error) => "generic Ext replay failed: {error}";
Self::CountMismatch { field } => "atlas artifact count field {field} is inconsistent";
Self::ReplayMismatch { field } => "atlas artifact replay differs at {field}";
Self::VerificationLimit { field, declared, limit } => "atlas artifact verification field {field} has {declared}, limit {limit}";
Self::Overflow { field } => "atlas artifact count overflows while checking {field}";
} }
error_source! { CatalogAtlasArtifactError {
Self::Certificate(error) => Some(error),
Self::Verify(error) => Some(error),
Self::Algebra(error) => Some(error),
Self::Atlas(error) => Some(error),
Self::Multiplicity(error) => Some(error),
Self::Score(error) => Some(error),
Self::Ext(error) => Some(error),
Self::Field(error) => Some(error),
_ => None,
} }
from_variants! { CatalogAtlasArtifactError {
CertParseError => Certificate,
VerifyError => Verify,
AlgebraBuildError => Algebra,
FieldError => Field,
crate::atlas::CatalogAtlasError => Atlas,
crate::atlas::MultiplicityError => Multiplicity,
AtlasScoreError => Score,
ExtError => Ext,
} }