about summary refs log tree commit diff
path: root/tvix/eval/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/errors.rs')
-rw-r--r--tvix/eval/src/errors.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index a7d54d51bb27..3ba3404a8d12 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -158,6 +158,17 @@ impl From<io::Error> for ErrorKind {
     }
 }
 
+impl ErrorKind {
+    /// Returns `true` if this error can be caught by `builtins.tryEval`
+    pub fn is_catchable(&self) -> bool {
+        match self {
+            Self::Throw(_) | Self::AssertionFailed => true,
+            Self::ThunkForce(err) => err.kind.is_catchable(),
+            _ => false,
+        }
+    }
+}
+
 #[derive(Clone, Debug)]
 pub struct Error {
     pub kind: ErrorKind,