Extra safe error adapters (#556)
Catching and logging all unexpected errors that occur in the error adapters _**just in case**_
This commit is contained in:
parent
9c1b2b9275
commit
f50e05aa9b
4 changed files with 15 additions and 6 deletions
|
|
@ -75,9 +75,9 @@ class GoogleErrorAdapter:
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to extract request details if available
|
# Try to extract request details if available
|
||||||
if hasattr(error, "uri"):
|
if hasattr(error, "uri") and error.uri:
|
||||||
extra["endpoint"] = self._sanitize_uri(error.uri)
|
extra["endpoint"] = self._sanitize_uri(error.uri)
|
||||||
if hasattr(error, "method_"):
|
if hasattr(error, "method_") and error.method_:
|
||||||
extra["http_method"] = error.method_.upper()
|
extra["http_method"] = error.method_.upper()
|
||||||
|
|
||||||
# Special case for rate limiting
|
# Special case for rate limiting
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
|
import logging
|
||||||
from typing import Any, Callable, TypeVar
|
from typing import Any, Callable, TypeVar
|
||||||
|
|
||||||
from arcade_tdk.auth import ToolAuthorization
|
from arcade_tdk.auth import ToolAuthorization
|
||||||
|
|
@ -14,6 +15,8 @@ from arcade_tdk.utils import snake_to_pascal_case
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _build_adapter_chain(
|
def _build_adapter_chain(
|
||||||
adapters: list[ErrorAdapter] | None, auth_provider: ToolAuthorization | None
|
adapters: list[ErrorAdapter] | None, auth_provider: ToolAuthorization | None
|
||||||
|
|
@ -81,7 +84,13 @@ def _raise_as_arcade_error(
|
||||||
ToolRuntimeError or some subclass thereof
|
ToolRuntimeError or some subclass thereof
|
||||||
"""
|
"""
|
||||||
for adapter in adapter_chain:
|
for adapter in adapter_chain:
|
||||||
mapped = adapter.from_exception(exception)
|
try:
|
||||||
|
mapped = adapter.from_exception(exception)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
f"Failed to map exception to Arcade Error with adapter {adapter.slug}: {e}"
|
||||||
|
)
|
||||||
|
continue
|
||||||
if isinstance(mapped, ToolRuntimeError):
|
if isinstance(mapped, ToolRuntimeError):
|
||||||
raise mapped from exception
|
raise mapped from exception
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "arcade-tdk"
|
name = "arcade-tdk"
|
||||||
version = "2.3.0"
|
version = "2.3.1"
|
||||||
description = "Arcade TDK - Toolkit Development Kit for building Arcade tools"
|
description = "Arcade TDK - Toolkit Development Kit for building Arcade tools"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {text = "MIT"}
|
license = {text = "MIT"}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "arcade-ai"
|
name = "arcade-ai"
|
||||||
version = "2.2.0"
|
version = "2.2.1"
|
||||||
description = "Arcade.dev - Tool Calling platform for Agents"
|
description = "Arcade.dev - Tool Calling platform for Agents"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {file = "LICENSE"}
|
license = {file = "LICENSE"}
|
||||||
|
|
@ -42,7 +42,7 @@ all = [
|
||||||
# serve
|
# serve
|
||||||
"arcade-serve>=2.1.0,<3.0.0",
|
"arcade-serve>=2.1.0,<3.0.0",
|
||||||
# tdk
|
# tdk
|
||||||
"arcade-tdk>=2.3.0,<3.0.0",
|
"arcade-tdk>=2.3.1,<3.0.0",
|
||||||
]
|
]
|
||||||
# Evals also depends on arcade-core and openai, but they are already required deps
|
# Evals also depends on arcade-core and openai, but they are already required deps
|
||||||
evals = [
|
evals = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue