use std::fmt;
use crate::AddressType;
#[derive(Clone, PartialEq)]
#[derive(Debug)]
pub enum Error {
Syntax(String, usize),
InvalidIdentifier(String, usize),
IntegerTooBig(usize),
FileNotFound(String),
#[doc(hidden)]
__NonExhaustive,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Syntax(ref err, ref line) => write!(
f,
"{} on line {}.",
err,
line
),
Error::IntegerTooBig(ref line) => write!(
f,
"Integer exceeds size limit of {} on line {}.",
AddressType::MAX,
line
),
Error::InvalidIdentifier(ref identifier, ref line) => write!(
f,
"Invalid identifier \"{}\" on line {}.",
identifier,
line
),
Error::FileNotFound(path) => write!(
f,
"File at \"{}\" was not found.",
path
),
Error::__NonExhaustive => unreachable!(),
}
}
}