Private
Public Access
refactor(ai_client): remove ProviderError class; ErrorInfo is the new error type
This commit is contained in:
@@ -76,31 +76,6 @@ _history_trunc_limit: int = 8000
|
||||
# Global event emitter for API lifecycle events
|
||||
events: EventEmitter = EventEmitter()
|
||||
|
||||
class ProviderError(Exception):
|
||||
def __init__(self, kind: str, provider: str, original: Exception) -> None:
|
||||
"""
|
||||
[C: src/api_hooks.py:HookServerInstance.__init__, src/mcp_client.py:_DDGParser.__init__, src/mcp_client.py:_TextExtractor.__init__]
|
||||
"""
|
||||
self.kind = kind
|
||||
self.provider = provider
|
||||
self.original = original
|
||||
super().__init__(str(original))
|
||||
|
||||
def ui_message(self) -> str:
|
||||
"""
|
||||
[C: src/app_controller.py:AppController._handle_request_event, src/app_controller.py:_api_generate]
|
||||
"""
|
||||
labels = {
|
||||
"quota": "QUOTA EXHAUSTED",
|
||||
"rate_limit": "RATE LIMITED",
|
||||
"auth": "AUTH / API KEY ERROR",
|
||||
"balance": "BALANCE / BILLING ERROR",
|
||||
"network": "NETWORK / CONNECTION ERROR",
|
||||
"unknown": "API ERROR",
|
||||
}
|
||||
label = labels.get(self.kind, "API ERROR")
|
||||
return f"[{self.provider.upper()} {label}]\n\n{self.original}"
|
||||
|
||||
#region: Provider Configuration
|
||||
|
||||
def set_model_params(temp: float, max_tok: int, trunc_limit: int = 8000, top_p: float = 1.0) -> None:
|
||||
@@ -1451,9 +1426,6 @@ def _send_anthropic_result(md_content: str, user_message: str, base_dir: str, fi
|
||||
res = final_text if final_text.strip() else "(No text returned by the model)"
|
||||
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
||||
return Result(data=res)
|
||||
except ProviderError:
|
||||
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
||||
raise
|
||||
except Exception as exc:
|
||||
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
||||
return Result(data="", errors=[_classify_anthropic_error(exc, source="ai_client.anthropic")])
|
||||
|
||||
Reference in New Issue
Block a user