use crate::ar::TauError;
use crate::arquiver::ArQuiverError;
use crate::ext::ExtClassError;
use crate::hom::HomError;
use crate::homspace::HomSpaceError;
use crate::indec::IndecError;
use crate::sequence::SequenceError;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum DefectKind {
DualityDimensionMismatch {
ext_dim: usize,
stable_end_dim: usize,
},
SocleDimensionMismatch {
socle_dim: usize,
residue_degree: usize,
},
ProjectivityDisagreement {
resolution_projective: bool,
tau_zero: bool,
},
NonzeroClassSplit,
RightFactorizationMismatch {
entry: usize,
},
LeftFactorizationMismatch {
entry: usize,
},
}
display_error! { DefectKind {
Self::DualityDimensionMismatch { ext_dim, stable_end_dim } => "Ext^1(M, tau M) has dimension {ext_dim}, stable End(M) has dimension {stable_end_dim}; crate defect";
Self::SocleDimensionMismatch { socle_dim, residue_degree } => "the Ext socle has dimension {socle_dim}, the residue degree is {residue_degree}; crate defect";
Self::ProjectivityDisagreement { resolution_projective, tau_zero } => "the resolution route reports projective = {resolution_projective}, tau reports zero = {tau_zero}; crate defect";
Self::NonzeroClassSplit => "the sequence of a nonzero chosen class splits; crate defect";
Self::RightFactorizationMismatch { entry } => "the image of Hom(X, E) in Hom(X, M) differs from rad(X, M) at catalog entry {entry}; crate defect";
Self::LeftFactorizationMismatch { entry } => "the image of Hom(E, X) in Hom(tau M, X) differs from rad(tau M, X) at catalog entry {entry}; crate defect";
} }
#[derive(Clone, Debug)]
pub enum AlmostSplitError {
Tau(TauError),
TauIndecomposability(IndecError),
Hom(HomError),
Space(HomSpaceError),
Ext(ExtClassError),
Sequence(SequenceError),
Radical(ArQuiverError),
Defect(DefectKind),
}
display_error! { error AlmostSplitError {
Self::Tau(error) => "the AR translate failed: {error}";
Self::TauIndecomposability(error) => "the translate failed the indecomposability gate: {error}";
Self::Hom(error) => "morphism rejected: {error}";
Self::Space(error) => "hom space rejected the input: {error}";
Self::Ext(error) => "Ext class rejected the input: {error}";
Self::Sequence(error) => "short exact sequence rejected: {error}";
Self::Radical(error) => "category radical failed: {error}";
Self::Defect(kind) => "internal cross-check failed: {kind}";
} }
from_variants!(AlmostSplitError {
TauError => Tau,
IndecError => TauIndecomposability,
HomError => Hom,
HomSpaceError => Space,
ExtClassError => Ext,
SequenceError => Sequence,
ArQuiverError => Radical,
});
pub(in crate::almost_split) fn defect(kind: DefectKind) -> AlmostSplitError {
AlmostSplitError::Defect(kind)
}