Private
Public Access
refactor(ai_client): classifier functions return ErrorInfo instead of ProviderError
The 6 error-classifier functions in ai_client.py, openai_compatible.py, and qwen_adapter.py now return ErrorInfo (data-oriented) instead of ProviderError. Each takes a source: str parameter for telemetry provenance. ProviderError class is still used in production code paths (Task 3.4) and will be removed in Task 3.7.
This commit is contained in:
+8
-8
@@ -8,7 +8,7 @@ from dashscope.common.error import (
|
||||
ServiceUnavailableError,
|
||||
TimeoutException,
|
||||
)
|
||||
from src.ai_client import ProviderError
|
||||
from src.result_types import ErrorInfo, ErrorKind
|
||||
|
||||
def build_dashscope_tools(openai_tools: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
out: list[dict[str, Any]] = []
|
||||
@@ -23,15 +23,15 @@ def build_dashscope_tools(openai_tools: list[dict[str, Any]]) -> list[dict[str,
|
||||
})
|
||||
return out
|
||||
|
||||
def classify_dashscope_error(exc: Exception) -> ProviderError:
|
||||
def classify_dashscope_error(exc: Exception, source: str = "qwen_adapter") -> ErrorInfo:
|
||||
if isinstance(exc, AuthenticationError):
|
||||
return ProviderError(kind="auth", provider="qwen", original=exc)
|
||||
return ErrorInfo(kind=ErrorKind.AUTH, message=str(exc), source=source, original=exc)
|
||||
if isinstance(exc, TimeoutException):
|
||||
return ProviderError(kind="network", provider="qwen", original=exc)
|
||||
return ErrorInfo(kind=ErrorKind.NETWORK, message=str(exc), source=source, original=exc)
|
||||
if isinstance(exc, ServiceUnavailableError):
|
||||
return ProviderError(kind="network", provider="qwen", original=exc)
|
||||
return ErrorInfo(kind=ErrorKind.NETWORK, message=str(exc), source=source, original=exc)
|
||||
if isinstance(exc, InvalidParameter):
|
||||
return ProviderError(kind="quota", provider="qwen", original=exc)
|
||||
return ErrorInfo(kind=ErrorKind.QUOTA, message=str(exc), source=source, original=exc)
|
||||
if isinstance(exc, RequestFailure):
|
||||
return ProviderError(kind="network", provider="qwen", original=exc)
|
||||
return ProviderError(kind="unknown", provider="qwen", original=exc)
|
||||
return ErrorInfo(kind=ErrorKind.NETWORK, message=str(exc), source=source, original=exc)
|
||||
return ErrorInfo(kind=ErrorKind.UNKNOWN, message=str(exc), source=source, original=exc)
|
||||
|
||||
Reference in New Issue
Block a user