Skip to content

Commit

Permalink
errors: A couple more starlark::Errors
Browse files Browse the repository at this point in the history
Summary: There's a function here where we turn `ValueError`s into `anyhow::Error`s, causing us to lose categorization. Turn them into `crate::Error`s instead

Reviewed By: iguridi

Differential Revision: D52105753

fbshipit-source-id: 3f74342e89a3de50a0f45b43cbdd861787a833b1
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Dec 13, 2023
1 parent 533a69a commit c3d37b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions starlark/src/eval/compiler/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ impl<P: AstPayload> CompilerExprUtil<P> for ExprP<P> {

#[cold]
#[inline(never)]
fn get_attr_no_attr_error<'v>(x: Value<'v>, attribute: &Symbol) -> anyhow::Error {
fn get_attr_no_attr_error<'v>(x: Value<'v>, attribute: &Symbol) -> crate::Error {
match did_you_mean(attribute.as_str(), x.dir_attr().iter().map(|s| s.as_str())) {
None => ValueError::NoAttr(x.get_type().to_owned(), attribute.as_str().to_owned()).into(),
Some(better) => ValueError::NoAttrDidYouMean(
Expand Down Expand Up @@ -1120,7 +1120,7 @@ pub(crate) fn get_attr_hashed_raw<'v>(
x: Value<'v>,
attribute: &Symbol,
heap: &'v Heap,
) -> anyhow::Result<MemberOrValue<'v>> {
) -> crate::Result<MemberOrValue<'v>> {
let aref = x.get_ref();
if let Some(methods) = aref.vtable().methods() {
if let Some(v) = methods.get_frozen_symbol(attribute) {
Expand All @@ -1145,7 +1145,7 @@ pub(crate) fn get_attr_hashed_bind<'v>(
}
}
match aref.get_attr_hashed(attribute.as_str_hashed(), heap) {
None => Err(get_attr_no_attr_error(x, attribute).into()),
None => Err(get_attr_no_attr_error(x, attribute)),
Some(x) => {
// Only `get_methods` is allowed to return unbound methods or attributes.
// Both types are crate private, so we assume `get_attr` never returns them.
Expand Down

0 comments on commit c3d37b1

Please sign in to comment.