diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-09-09T07·10-0700 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-09-24T21·54+0000 |
commit | 926459ce694536432c36d8f0d3fb25b821945852 (patch) | |
tree | 2c5509c92afec80b281f82761f19ee192a85851a /tvix/eval/src/nix_search_path.rs | |
parent | 6015604bd81e064da8253c58825315a3b8e47b30 (diff) |
refactor(tvix/eval): factor CatchableErrorKind out of ErrorKind r/6649
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>
Diffstat (limited to 'tvix/eval/src/nix_search_path.rs')
-rw-r--r-- | tvix/eval/src/nix_search_path.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tvix/eval/src/nix_search_path.rs b/tvix/eval/src/nix_search_path.rs index 79c19752f6c1..3e553e62bb85 100644 --- a/tvix/eval/src/nix_search_path.rs +++ b/tvix/eval/src/nix_search_path.rs @@ -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:?}" ); } |