forked from AbleScript/ablescript
Renamed few errors
This commit is contained in:
parent
8c9e49a7c4
commit
8c101aee23
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue