Skip to content

Commit

Permalink
errors: Even more downcast using buck2_error
Browse files Browse the repository at this point in the history
Summary: I'm not sure if we should keep the `EvalMessage::from_anyhow` function around. Tbh libraries should never accept `anyhow::Error`s like this, and they certainly shouldn't downcast them. But whatever, I don't care too much right now

Reviewed By: wendy728

Differential Revision: D50213712

fbshipit-source-id: 1f1f8d871d2b690a5ced0e8b9817074675e978fb
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Oct 17, 2023
1 parent ffe8e10 commit 78639ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion starlark/src/analysis/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl Display for EvalMessage {
}

impl EvalMessage {
/// Convert from an `anyhow::Error`, including some type checking, to an `EvalMessage`
/// Convert from an `anyhow::Error` to an `EvalMessage`.
///
/// This will attempt to downcast the error to a `Diagnostic`.
pub fn from_anyhow(file: &Path, x: &anyhow::Error) -> Self {
match x.downcast_ref::<Diagnostic>() {
Some(d) => Self::from_diagnostic(file, d),
Expand Down

0 comments on commit 78639ff

Please sign in to comment.