Renamed few errors
This commit is contained in:
parent
766eb799c9
commit
28a5415207
|
@ -14,10 +14,10 @@ pub enum ErrorKind {
|
||||||
UnknownVariable(String),
|
UnknownVariable(String),
|
||||||
MeloVariable(String),
|
MeloVariable(String),
|
||||||
TopLevelBreak,
|
TopLevelBreak,
|
||||||
BfInterpretError(InterpretError),
|
MismatchedArity,
|
||||||
MismatchedArgumentError,
|
|
||||||
MissingLhs,
|
MissingLhs,
|
||||||
IoError(io::Error),
|
Brian(InterpretError),
|
||||||
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
@ -52,17 +52,17 @@ impl Display for ErrorKind {
|
||||||
ErrorKind::UnknownVariable(name) => write!(f, "unknown identifier \"{}\"", name),
|
ErrorKind::UnknownVariable(name) => write!(f, "unknown identifier \"{}\"", name),
|
||||||
ErrorKind::MeloVariable(name) => write!(f, "banned variable \"{}\"", name),
|
ErrorKind::MeloVariable(name) => write!(f, "banned variable \"{}\"", name),
|
||||||
ErrorKind::TopLevelBreak => write!(f, "can only `break` out of a loop"),
|
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.
|
// 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::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 {
|
impl From<io::Error> for ErrorKind {
|
||||||
fn from(e: io::Error) -> Self {
|
fn from(e: io::Error) -> Self {
|
||||||
Self::IoError(e)
|
Self::Io(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,7 +428,7 @@ impl ExecEnv {
|
||||||
)
|
)
|
||||||
.interpret_with_output(&mut output)
|
.interpret_with_output(&mut output)
|
||||||
.map_err(|e| Error {
|
.map_err(|e| Error {
|
||||||
kind: ErrorKind::BfInterpretError(e),
|
kind: ErrorKind::Brian(e),
|
||||||
span: span.to_owned(),
|
span: span.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ impl ExecEnv {
|
||||||
Functio::Able { params, body } => {
|
Functio::Able { params, body } => {
|
||||||
if params.len() != args.len() {
|
if params.len() != args.len() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::MismatchedArgumentError,
|
kind: ErrorKind::MismatchedArity,
|
||||||
span: span.to_owned(),
|
span: span.to_owned(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,7 @@ impl ExecEnv {
|
||||||
Functio::Eval(code) => {
|
Functio::Eval(code) => {
|
||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::MismatchedArgumentError,
|
kind: ErrorKind::MismatchedArity,
|
||||||
span: span.to_owned(),
|
span: span.to_owned(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue