use crate::code_type::CodeType;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MecoError {
MissTranslateRule(CodeType),
NothingToPop,
NotFoundInMapper(String),
NotSupportedCodeSeries(CodeType),
UnsupportedEnumType(String),
Unsupported(CodeType),
Utn57(String),
}
impl fmt::Display for MecoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MecoError::MissTranslateRule(ct) => write!(f, "missing translate rule for {ct:?}"),
MecoError::NothingToPop => write!(f, "nothing to pop"),
MecoError::NotFoundInMapper(k) => write!(f, "key not found in mapper: {k:?}"),
MecoError::NotSupportedCodeSeries(ct) => write!(f, "unsupported code series for {ct:?}"),
MecoError::UnsupportedEnumType(s) => write!(f, "unsupported encoding name: {s:?}"),
MecoError::Unsupported(ct) => write!(f, "conversion not supported for {ct:?}"),
MecoError::Utn57(reason) => write!(f, "UTN #57 conversion failed: {reason}"),
}
}
}
impl std::error::Error for MecoError {}