Refine error message.
This commit is contained in:
parent
fcc7589ffc
commit
f458f18ffa
@ -109,7 +109,7 @@ fn print_error(input: &str, mut err: EvalAltResult) {
|
||||
// Display position marker
|
||||
println!(
|
||||
"\x1b[31m{0:>1$}{err_line}\x1b[39m",
|
||||
if i > 0 { " " } else { "^ " },
|
||||
if i > 0 { "| " } else { "^ " },
|
||||
line_no.len() + pos.position().unwrap() + 1,
|
||||
);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ fn print_error(input: &str, mut err: EvalAltResult) {
|
||||
// Display position marker
|
||||
println!(
|
||||
"{0:>1$}{err_line}",
|
||||
if i > 0 { " " } else { "^ " },
|
||||
if i > 0 { "| " } else { "^ " },
|
||||
line_no.len() + pos.position().unwrap() + 1,
|
||||
);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ fn eprint_error(input: &str, mut err: EvalAltResult) {
|
||||
// Display position marker
|
||||
println!(
|
||||
"{0:>1$}{err_line}",
|
||||
if i > 0 { " " } else { "^ " },
|
||||
if i > 0 { "| " } else { "^ " },
|
||||
line_no.len() + pos.position().unwrap() + 1,
|
||||
);
|
||||
}
|
||||
|
@ -135,20 +135,20 @@ impl fmt::Display for EvalAltResult {
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::ErrorInFunctionCall(s, src, err, ..) if crate::parser::is_anonymous_fn(s) => {
|
||||
write!(f, "{err}\n| in closure call")?;
|
||||
write!(f, "{err}\nin closure call")?;
|
||||
if !src.is_empty() {
|
||||
write!(f, " @ '{src}'")?;
|
||||
}
|
||||
}
|
||||
Self::ErrorInFunctionCall(s, src, err, ..) => {
|
||||
write!(f, "{err}\n| in call to function '{s}'")?;
|
||||
write!(f, "{err}\nin call to function '{s}'")?;
|
||||
if !src.is_empty() {
|
||||
write!(f, " @ '{src}'")?;
|
||||
}
|
||||
}
|
||||
|
||||
Self::ErrorInModule(s, err, ..) if s.is_empty() => write!(f, "{err}\n| in module")?,
|
||||
Self::ErrorInModule(s, err, ..) => write!(f, "{err}\n| in module '{s}'")?,
|
||||
Self::ErrorInModule(s, err, ..) if s.is_empty() => write!(f, "{err}\nin module")?,
|
||||
Self::ErrorInModule(s, err, ..) => write!(f, "{err}\nin module '{s}'")?,
|
||||
|
||||
Self::ErrorVariableExists(s, ..) => write!(f, "Variable already defined: {s}")?,
|
||||
Self::ErrorForbiddenVariable(s, ..) => write!(f, "Forbidden variable name: {s}")?,
|
||||
|
Loading…
Reference in New Issue
Block a user