feat(tvix/eval): add error contexts to annotate error kinds
This makes it possible for users to add additional context to an error, which will then be rendered as an additional secondary span in the formatted error output. We should strive to do this basically anywhere errors are raised that can occur multiple times, *especially* during type casts. This was triggered by me debugging a type cast error attached to a fairly large-ish span (a builtin invocation). Change-Id: I51be41fabee00cf04de973935daf34fe6424e76f Reviewed-on: https://cl.tvl.fyi/c/depot/+/7849 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
148a63ae7e
commit
972c867b36
5 changed files with 99 additions and 34 deletions
|
@ -48,7 +48,7 @@ use crate::vm::run_lambda;
|
|||
|
||||
// Re-export the public interface used by other crates.
|
||||
pub use crate::compiler::{compile, prepare_globals, CompilationOutput};
|
||||
pub use crate::errors::{Error, ErrorKind, EvalResult};
|
||||
pub use crate::errors::{AddContext, Error, ErrorKind, EvalResult};
|
||||
pub use crate::io::{DummyIO, EvalIO, FileType};
|
||||
pub use crate::pretty_ast::pretty_print_expr;
|
||||
pub use crate::source::SourceCode;
|
||||
|
@ -278,10 +278,10 @@ fn parse_compile_internal(
|
|||
let parse_errors = parsed.errors();
|
||||
|
||||
if !parse_errors.is_empty() {
|
||||
result.errors.push(Error {
|
||||
kind: ErrorKind::ParseErrors(parse_errors.to_vec()),
|
||||
span: file.span,
|
||||
});
|
||||
result.errors.push(Error::new(
|
||||
ErrorKind::ParseErrors(parse_errors.to_vec()),
|
||||
file.span,
|
||||
));
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue