From c3d37b13ef5a232c2d1190a5bbec30e719e803f3 Mon Sep 17 00:00:00 2001 From: Jakob Degen Date: Wed, 13 Dec 2023 09:17:57 -0800 Subject: [PATCH] errors: A couple more `starlark::Error`s 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 --- starlark/src/eval/compiler/expr.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/starlark/src/eval/compiler/expr.rs b/starlark/src/eval/compiler/expr.rs index 88ad3da79..609933af2 100644 --- a/starlark/src/eval/compiler/expr.rs +++ b/starlark/src/eval/compiler/expr.rs @@ -1089,7 +1089,7 @@ impl CompilerExprUtil

for ExprP

{ #[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( @@ -1120,7 +1120,7 @@ pub(crate) fn get_attr_hashed_raw<'v>( x: Value<'v>, attribute: &Symbol, heap: &'v Heap, -) -> anyhow::Result> { +) -> crate::Result> { let aref = x.get_ref(); if let Some(methods) = aref.vtable().methods() { if let Some(v) = methods.get_frozen_symbol(attribute) { @@ -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.