| 114 | |
| 115 | // 处理API错误响应 |
| 116 | export const handleApiError = (error, response = null) => { |
| 117 | const errorInfo = { |
| 118 | error: error.message || '未知错误', |
| 119 | timestamp: new Date().toISOString(), |
| 120 | stack: error.stack |
| 121 | }; |
| 122 | |
| 123 | if (response) { |
| 124 | errorInfo.status = response.status; |
| 125 | errorInfo.statusText = response.statusText; |
| 126 | } |
| 127 | |
| 128 | if (error.message.includes('HTTP error')) { |
| 129 | errorInfo.details = '服务器返回了错误状态码'; |
| 130 | } else if (error.message.includes('Failed to fetch')) { |
| 131 | errorInfo.details = '网络连接失败或服务器无响应'; |
| 132 | } |
| 133 | |
| 134 | return errorInfo; |
| 135 | }; |
| 136 | |
| 137 | // 处理模型数据 |
| 138 | export const processModelsData = (data, currentModel) => { |