Renamed few errors

trunk
ondra05 2022-05-06 17:25:50 +02:00
parent f62c44ff01
commit 39e46f090d
2 changed files with 10 additions and 10 deletions

View File

@ -14,10 +14,10 @@ pub enum ErrorKind {
UnknownVariable(String),
MeloVariable(String),
TopLevelBreak,
BfInterpretError(InterpretError),
MismatchedArgumentError,
MismatchedArity,
MissingLhs,
IoError(io::Error),
Brian(InterpretError),
Io(io::Error),
}
impl Error {
@ -52,17 +52,17 @@ impl Display for ErrorKind {
ErrorKind::UnknownVariable(name) => write!(f, "unknown identifier \"{}\"", name),
ErrorKind::MeloVariable(name) => write!(f, "banned variable \"{}\"", name),
ErrorKind::TopLevelBreak => write!(f, "can only `break` out of a loop"),
ErrorKind::BfInterpretError(err) => write!(f, "brainfuck error: {}", err),
ErrorKind::Brian(err) => write!(f, "brainfuck error: {}", err),
// TODO: give concrete numbers here.
ErrorKind::MismatchedArgumentError => write!(f, "wrong number of function arguments"),
ErrorKind::MismatchedArity => write!(f, "wrong number of function arguments"),
ErrorKind::MissingLhs => write!(f, "missing expression before binary operation"),
ErrorKind::IoError(err) => write!(f, "I/O error: {}", err),
ErrorKind::Io(err) => write!(f, "I/O error: {}", err),
}
}
}
impl From<io::Error> for ErrorKind {
fn from(e: io::Error) -> Self {
Self::IoError(e)
Self::Io(e)
}
}

View File

@ -428,7 +428,7 @@ impl ExecEnv {
)
.interpret_with_output(&mut output)
.map_err(|e| Error {
kind: ErrorKind::BfInterpretError(e),
kind: ErrorKind::Brian(e),
span: span.to_owned(),
})?;
@ -439,7 +439,7 @@ impl ExecEnv {
Functio::Able { params, body } => {
if params.len() != args.len() {
return Err(Error {
kind: ErrorKind::MismatchedArgumentError,
kind: ErrorKind::MismatchedArity,
span: span.to_owned(),
});
}
@ -477,7 +477,7 @@ impl ExecEnv {
Functio::Eval(code) => {
if !args.is_empty() {
return Err(Error {
kind: ErrorKind::MismatchedArgumentError,
kind: ErrorKind::MismatchedArity,
span: span.to_owned(),
});
}