Skip to content

Commit

Permalink
codehub: starlark::Error compatibility, part 2
Browse files Browse the repository at this point in the history
Summary: Nearby but not strictly related code to the previous diff. Mostly the same story.

Reviewed By: stepancheg

Differential Revision: D51574787

fbshipit-source-id: a3947ac896ff3fe1aa93ec5dde1f488ba20d2e84
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Nov 28, 2023
1 parent 041d477 commit 8aabbc8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions starlark_syntax/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ impl Error {
&self.0.kind
}

/// Convert the error into the underlying kind
pub fn into_kind(self) -> ErrorKind {
self.0.kind
}

pub fn has_diagnostic(&self) -> bool {
self.0.diagnostic.is_some()
|| match self.kind() {
ErrorKind::Other(e) => e.downcast_ref::<Diagnostic>().is_some(),
}
}

/// Convert this error into an `anyhow::Error`
pub fn into_anyhow(self) -> anyhow::Error {
struct Wrapped(Error);
Expand Down

0 comments on commit 8aabbc8

Please sign in to comment.