feat(tvix/composition): downcast boxed error if possible

We still have the unique store name to identify which instantiation caused the error. For recursion errors, the full chain is still retained inside the CompositionError.

Change-Id: Iaddcece445a5df331e578d7c69d710db3d5f8dcd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12002
Tested-by: BuildkiteCI
Autosubmit: yuka <yuka@yuka.dev>
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Yureka 2024-07-21 15:19:16 +02:00 committed by clbot
parent 1f89cf9027
commit 76394daca3

View file

@ -431,10 +431,13 @@ impl Composition {
new_context
.stack
.push((TypeId::of::<T>(), entrypoint.clone()));
let res = config
.build(&entrypoint, &new_context)
.await
.map_err(|e| CompositionError::Failed(entrypoint, e.into()));
let res =
config.build(&entrypoint, &new_context).await.map_err(|e| {
match e.downcast() {
Ok(e) => *e,
Err(e) => CompositionError::Failed(entrypoint, e.into()),
}
});
tx.send(Some(res.clone())).unwrap();
res
})