From ea80e0d3f88576ef593b1f9237bd51da9c3f335b Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 12 Mar 2023 18:06:11 +0300 Subject: feat(tvix/eval): enrich errors with VM's frame stack information When emitting an error at runtime, the VM will now use the new `NativeError` and `BytecodeError` error kinds (which just wrap inner errors) to create a set of diagnostics to emit. The primary diagnostic is emitted last, with `error` type (so it will be coloured red in terminals), the other ones will be emitted with `note` type, highlighting the causal chain. Example: https://gist.github.com/tazjin/25feba7d211702453c9ebd5f8fd378e4 This is currently quite verbose, and we can cut down on this further, but the purpose of this commit is to surface more information first of all before worrying about the exact display. Change-Id: I058104a178c37031c0db6b4b3e4f4170cf76087d Reviewed-on: https://cl.tvl.fyi/c/depot/+/8266 Autosubmit: tazjin Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/eval/src/compiler/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/compiler/mod.rs') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 39b706cb487a..9cbbf62dbd0a 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -1339,7 +1339,8 @@ fn compile_src_builtin( file.clone(), weak.upgrade().unwrap(), &mut crate::observer::NoOpObserver {}, - )?; + ) + .map_err(|e| ErrorKind::NativeError(Box::new(e)))?; if !result.errors.is_empty() { return Err(ErrorKind::ImportCompilerError { -- cgit 1.4.1