Skip to content

Commit

Permalink
Remove unused label from runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
certainty committed Sep 4, 2021
1 parent b6f985e commit 2907936
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/vm/error/reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,27 @@ impl<'a> ErrorReporter<'a> {
e: &RuntimeError,
line: usize,
stack_trace: StackTrace,
label: Option<String>,
_label: Option<String>,
) {
eprintln!(
"{} on line {} [in {}]\n{}",
e,
"{} on line {}\n{}",
self.runtime_error_message(e),
line,
label.unwrap_or_default(),
stack_trace.as_string()
)
}

pub fn runtime_error_message(&self, e: RuntimeError) -> String {
pub fn runtime_error_message(&self, e: &RuntimeError) -> String {
match e {
RuntimeError::ArgumentError(value, message) => {
format!("ArgumentError: {:?} {}", value, message)
}
RuntimeError::ArithmeticError(message) => format!("ArithmeticError: {}", message),
RuntimeError::ArityError(arity, argc) => format!("ArityError: {:?} {}", arity, argc),
RuntimeError::NoncallableError(v) => format!("NonCallable: {:?}", v),
RuntimeError::UndefinedVariable(s) => format!("UndefineVariabel: {:?}", s),
RuntimeError::UndefinedVariable(s) => {
format!("UndefinedVariable: Variable `{}` is undefined", s.as_str())
}
}
}
}
4 changes: 2 additions & 2 deletions src/vm/value/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use thiserror::Error;

#[derive(Error, Debug)]
pub enum RuntimeError {
#[error("UndefinedVariableError: Variable `{0:?}` is undefined")]
#[error("Undefined Variable")]
UndefinedVariable(Symbol),
#[error("ArityError: Function expected `{0:?}` arguments but received {1}")]
ArityError(Arity, usize),
#[error("ArgumentError: {1}")]
ArgumentError(Value, String),
#[error("AppplicationError: `{0:?}` is not callable")]
#[error("ApplicationError: `{0:?}` is not callable")]
NoncallableError(Value),
#[error("ArithmeticError: `{0}`")]
ArithmeticError(String),
Expand Down

0 comments on commit 2907936

Please sign in to comment.