From 972c867b365631f771f6933cd9a6384316d5aea5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 16 Jan 2023 20:02:33 +0300 Subject: 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 --- tvix/eval/src/value/thunk.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tvix/eval/src/value') diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index 23c60aa37815..2d48550dad97 100644 --- a/tvix/eval/src/value/thunk.rs +++ b/tvix/eval/src/value/thunk.rs @@ -197,10 +197,8 @@ impl Thunk { self_clone.0.replace(ThunkRepr::Evaluated(vm.pop())); assert!(matches!(should_be_blackhole, ThunkRepr::Blackhole)); vm.push(Value::Thunk(self_clone)); - Self::force_trampoline(vm).map_err(|kind| Error { - kind, - span: light_span.span(), - }) + Self::force_trampoline(vm) + .map_err(|kind| Error::new(kind, light_span.span())) })), }); } -- cgit 1.4.1