(error: Union[AppError, Exception, str], context: Optional[Dict[str, Any]] = None)
| 52 | |
| 53 | |
| 54 | def 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 | |
| 72 | def classify_error(error: Union[Exception, str], context: Optional[Dict[str, Any]] = None) -> AppError: |
no test coverage detected