diff options
author | Vincent Ambo <mail@tazj.in> | 2023-01-09T23·06+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-01-10T09·52+0000 |
commit | c011a6130cd4f0486539f8e98f0aef5d64e32d90 (patch) | |
tree | 5284f5171981b16c7b3b662a38701d05707c1f2f | |
parent | 0b9e1aca630916dbbbaabbe9afa3626bae49ac08 (diff) |
refactor(tvix/eval): impl Display for ErrorKind r/5639
This just shuffles the Display implementations around so that ErrorKind itself is displayable, which is useful in some situations where errors under construction need to be type-converted. Change-Id: I7b633d03d0dc34f345c4f20676e0023ecb1db0c4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7802 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: edef <edef@edef.eu> Tested-by: BuildkiteCI
-rw-r--r-- | tvix/eval/src/errors.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 2cef36f757a1..416a4b23c0d1 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -223,9 +223,9 @@ pub struct Error { pub span: Span, } -impl Display for Error { +impl Display for ErrorKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match &self.kind { + match &self { ErrorKind::Throw(msg) => write!(f, "error thrown: {}", msg), ErrorKind::Abort(msg) => write!(f, "evaluation aborted: {}", msg), ErrorKind::AssertionFailed => write!(f, "assertion failed"), @@ -409,6 +409,12 @@ to a missing value in the attribute set(s) included via `with`."#, } } +impl Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.kind) + } +} + pub type EvalResult<T> = Result<T, Error>; /// Human-readable names for rnix syntaxes. |