use crate::ar::TauError;
use crate::arquiver::CatalogError;
use crate::basic::BasicError;
use crate::hom::HomError;
use crate::taurigid::{NonTauRigidWitness, TauRigidError, TauRigidModule};
#[derive(Clone, Debug)]
pub enum SupportTauError {
Catalog(CatalogError),
Basic(BasicError),
TauRigid(TauRigidError),
Hom(HomError),
SummandIndexCount {
indices: usize,
summands: usize,
},
Defect {
reason: String,
},
}
display_error! { error SupportTauError {
Self::Catalog(error) => "the catalog route rejected the algebra: {error}";
Self::Basic(error) => "the basic layer rejected an input: {error}";
Self::TauRigid(error) => "tau-rigidity stayed undecided: {error}";
Self::Hom(error) => "a Hom space failed: {error}";
Self::SummandIndexCount { indices, summands } => "{indices} summand indices for {summands} summands; one index per summand";
Self::Defect { reason } => "internal cross-check failed: {reason}";
} }
from_variants!(SupportTauError {
CatalogError => Catalog,
BasicError => Basic,
TauRigidError => TauRigid,
});
impl From<TauError> for SupportTauError {
fn from(error: TauError) -> SupportTauError {
SupportTauError::TauRigid(TauRigidError::Tau(error))
}
}
from_variants!(SupportTauError { HomError => Hom });
#[derive(Clone, Debug)]
pub enum PairRejection {
DifferentAlgebras,
HomFromProjectiveNonzero {
vertex: u32,
dim: usize,
},
NotTauRigid(NonTauRigidWitness),
SummandCount {
module: usize,
projective: usize,
expected: usize,
},
}
impl PairRejection {
accessor_methods! {
pub condition() -> u32 = |this| match this {
Self::DifferentAlgebras => 1,
Self::HomFromProjectiveNonzero { .. } => 2,
Self::NotTauRigid(_) => 3,
Self::SummandCount { .. } => 4,
};
}
}
display_error! { PairRejection {
Self::DifferentAlgebras => "the two parts do not share one algebra";
Self::HomFromProjectiveNonzero { vertex, dim } => "Hom(P, M) is not zero: dim Hom(P_{vertex}, M) = dim M_{vertex} = {dim}";
Self::NotTauRigid(_) => "M is not tau-rigid";
Self::SummandCount { module, projective, expected } => "|M| + |P| = {module} + {projective}, and the pair needs {expected}";
} }
pub(super) enum Checked {
Accepted(TauRigidModule),
Rejected(PairRejection),
}