记录 API 错误日志 Args: endpoint: API 端点路径 error: 异常对象
(endpoint: str, error: Exception)
| 41 | |
| 42 | |
| 43 | def log_error(endpoint: str, error: Exception): |
| 44 | """ |
| 45 | 记录 API 错误日志 |
| 46 | |
| 47 | Args: |
| 48 | endpoint: API 端点路径 |
| 49 | error: 异常对象 |
| 50 | """ |
| 51 | logger.error(f"❌ 请求失败: {endpoint}") |
| 52 | logger.error(f" 错误类型: {type(error).__name__}") |
| 53 | logger.error(f" 错误信息: {str(error)}") |
| 54 | logger.debug(f" 堆栈跟踪:\n{traceback.format_exc()}") |
| 55 | |
| 56 | |
| 57 | def api_error_response(error, status: int = None, context: dict = None): |
no outgoing calls
no test coverage detected