mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-09 06:15:41 -05:00
fix: use getattr for pyright type checking on dynamic error attributes
Fixes pyright errors: - Cannot access attribute 'code' for class 'Exception' - Cannot access attribute 'param' for class 'Exception' Using getattr() instead of direct attribute access satisfies pyright's type checker while maintaining the same runtime behavior.
This commit is contained in:
@@ -1822,9 +1822,9 @@ def _extract_api_error_details(error: Exception) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
if hasattr(error, "code"):
|
||||
details["code"] = error.code
|
||||
details["code"] = getattr(error, "code", None)
|
||||
if hasattr(error, "param"):
|
||||
details["param"] = error.param
|
||||
details["param"] = getattr(error, "param", None)
|
||||
|
||||
if isinstance(error, APIStatusError):
|
||||
details["status_code"] = error.status_code
|
||||
|
||||
Reference in New Issue
Block a user