Skip to content

Commit

Permalink
error: add is_fatal helper
Browse files Browse the repository at this point in the history
This commit adds a method to `Error` for testing whether an error should
be considered fatal, e.g. should stop any further path building
progress.

Having this in a central place means we can avoid duplicating the match
arms in multiple places, where they are likely to fall out-of-sync.
  • Loading branch information
cpu committed Sep 7, 2023
1 parent f802b1e commit 87c220b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ impl Error {
Error::UnknownIssuer => 0,
}
}

/// Returns true for errors that should be considered fatal during path building. Errors of
/// this class should halt any further path building and be returned immediately.
#[inline]
pub(crate) fn is_fatal(&self) -> bool {
matches!(
self,
Error::MaximumSignatureChecksExceeded
| Error::MaximumPathBuildCallsExceeded
| Error::MaximumNameConstraintComparisonsExceeded
)
}
}

impl fmt::Display for Error {
Expand Down

0 comments on commit 87c220b

Please sign in to comment.