Prettier error handling
This commit is contained in:
parent
723719b9df
commit
2cb915dd24
11
src/repl.rs
11
src/repl.rs
|
@ -20,13 +20,20 @@ pub fn repl() {
|
||||||
Ok(ast) => {
|
Ok(ast) => {
|
||||||
println!("{:?}", ast);
|
println!("{:?}", ast);
|
||||||
println!("{:?}", env.eval_items(&ast));
|
println!("{:?}", env.eval_items(&ast));
|
||||||
},
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!(
|
println!(
|
||||||
"Error `{:?}` occured at span: {:?} = `{:?}`",
|
"Error `{:?}` occured at span: {:?} = `{:?}`",
|
||||||
e.kind,
|
e.kind,
|
||||||
e.position.clone(),
|
e.position.clone(),
|
||||||
line.slice(e.position)
|
line.slice(e.position.clone())
|
||||||
|
);
|
||||||
|
|
||||||
|
println!(" | {}", line);
|
||||||
|
println!(
|
||||||
|
" {}{}-- Here",
|
||||||
|
" ".repeat(e.position.start),
|
||||||
|
"^".repeat((e.position.end - e.position.start).max(1))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue