Skip to content

Commit

Permalink
downcast_anyhow to downcast_starlark
Browse files Browse the repository at this point in the history
Summary: Convert `downcast_anyhow` function to `downcast_starlark`. Required for anyhow->buck2_error migration in `buck2/app`

Reviewed By: christolliday

Differential Revision: D66196299

fbshipit-source-id: 1142df39fa7adf57e8bc61c82c8106fe77c4e65b
  • Loading branch information
Will-MingLun-Li authored and facebook-github-bot committed Nov 21, 2024
1 parent 7999bff commit 20b1037
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions starlark/src/values/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,15 @@ impl OwnedFrozenValue {
}

/// `downcast`, but return an error for human instead of original value.
pub fn downcast_anyhow<T: StarlarkValue<'static>>(
pub fn downcast_starlark<T: StarlarkValue<'static>>(
self,
) -> anyhow::Result<OwnedFrozenValueTyped<T>> {
) -> crate::Result<OwnedFrozenValueTyped<T>> {
match self.downcast() {
Ok(v) => Ok(v),
Err(this) => Err(OwnedError::WrongType(
Err(this) => Err(crate::Error::new_value(OwnedError::WrongType(
T::TYPE,
this.value.to_value().to_string_for_type_error(),
)
.into()),
))),
}
}

Expand Down

0 comments on commit 20b1037

Please sign in to comment.