feat(tvix/eval): use fancy error formatting in REPL
Change-Id: I8d5652d797b012bc3d5248ca2b2d0c87572dbf2e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6851 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com>
This commit is contained in:
parent
546f445f07
commit
d6643f66b1
3 changed files with 16 additions and 9 deletions
|
|
@ -81,21 +81,22 @@ pub fn interpret(code: &str, location: Option<PathBuf>, options: Options) -> Eva
|
|||
}
|
||||
|
||||
for error in &result.errors {
|
||||
eprintln!(
|
||||
"compiler error: {:?} at `{}`[line {}]",
|
||||
error.kind,
|
||||
file.source_slice(error.span),
|
||||
file.find_line(error.span.low()) + 1
|
||||
);
|
||||
error.fancy_format_stderr(&codemap);
|
||||
}
|
||||
|
||||
if let Some(err) = result.errors.last() {
|
||||
return Err(err.clone());
|
||||
}
|
||||
|
||||
if options.trace_runtime {
|
||||
let result = if options.trace_runtime {
|
||||
crate::vm::run_lambda(&mut TracingObserver::new(std::io::stderr()), result.lambda)
|
||||
} else {
|
||||
crate::vm::run_lambda(&mut NoOpObserver::default(), result.lambda)
|
||||
};
|
||||
|
||||
if let Err(err) = &result {
|
||||
err.fancy_format_stderr(&codemap);
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue