refactor(tvix/eval): impl Display for ErrorKind
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
This commit is contained in:
parent
0b9e1aca63
commit
c011a6130c
1 changed files with 8 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue