refactor(tvix/eval): factor CatchableErrorKind out of ErrorKind

This commit creates a separate enum for "catchable" errors (the kind
that `builtins.tryEval` can detect).

Change-Id: Ie81d1112526d852255d9842f67045f88eab192af
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9287
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: Adam Joseph <adam@westernsemico.com>
This commit is contained in:
Adam Joseph 2023-09-09 00:10:06 -07:00 committed by clbot
parent 6015604bd8
commit 926459ce69
5 changed files with 57 additions and 29 deletions

View file

@ -27,7 +27,7 @@ use std::rc::{Rc, Weak};
use std::sync::Arc;
use crate::chunk::Chunk;
use crate::errors::{Error, ErrorKind, EvalResult};
use crate::errors::{CatchableErrorKind, Error, ErrorKind, EvalResult};
use crate::observer::CompilerObserver;
use crate::opcode::{CodeIdx, ConstantIdx, Count, JumpOffset, OpCode, UpvalueIdx};
use crate::spans::LightSpan;
@ -398,7 +398,9 @@ impl Compiler<'_> {
if raw_path.len() == 2 {
return self.emit_error(
node,
ErrorKind::NixPathResolution("Empty <> path not allowed".into()),
ErrorKind::CatchableErrorKind(CatchableErrorKind::NixPathResolution(
"Empty <> path not allowed".into(),
)),
);
}
let path = &raw_path[1..(raw_path.len() - 1)];