MCPcopy
hub / github.com/HisMax/RedInk / ensure_app_error

Function ensure_app_error

backend/errors.py:54–69  ·  view source on GitHub ↗
(error: Union[AppError, Exception, str], context: Optional[Dict[str, Any]] = None)

Source from the content-addressed store, hash-verified

52
53
54def ensure_app_error(error: Union[AppError, Exception, str], context: Optional[Dict[str, Any]] = None) -> AppError:
55 if isinstance(error, AppError):
56 if context:
57 diagnostics = dict(error.diagnostics)
58 diagnostics.update(_sanitize_diagnostics(context))
59 return AppError(
60 code=error.code,
61 title=error.title,
62 detail=error.detail,
63 suggestion=error.suggestion,
64 status=error.status,
65 retryable=error.retryable,
66 diagnostics=diagnostics,
67 )
68 return error
69 return classify_error(error, context=context)
70
71
72def classify_error(error: Union[Exception, str], context: Optional[Dict[str, Any]] = None) -> AppError:

Callers 4

_normalize_sse_errorFunction · 0.90
api_error_responseFunction · 0.90
normalize_error_resultFunction · 0.90
error_payloadFunction · 0.85

Calls 3

_sanitize_diagnosticsFunction · 0.85
classify_errorFunction · 0.85
AppErrorClass · 0.70

Tested by

no test coverage detected