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

@ -3,7 +3,7 @@ use std::convert::Infallible;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use crate::errors::ErrorKind;
use crate::errors::{CatchableErrorKind, ErrorKind};
use crate::EvalIO;
#[derive(Debug, Clone, PartialEq, Eq)]
@ -134,10 +134,12 @@ impl NixSearchPath {
return Ok(p);
}
}
Err(ErrorKind::NixPathResolution(format!(
"path '{}' was not found in the Nix search path",
path.display()
)))
Err(ErrorKind::CatchableErrorKind(
CatchableErrorKind::NixPathResolution(format!(
"path '{}' was not found in the Nix search path",
path.display()
)),
))
}
}
@ -211,7 +213,10 @@ mod tests {
let mut io = StdIO {};
let err = nix_search_path.resolve(&mut io, "nope").unwrap_err();
assert!(
matches!(err, ErrorKind::NixPathResolution(..)),
matches!(
err,
ErrorKind::CatchableErrorKind(CatchableErrorKind::NixPathResolution(..))
),
"err = {err:?}"
);
}