* Implementation for logError - writes error to debug log and file.
(error: Error)
| 150 | * Implementation for logError - writes error to debug log and file. |
| 151 | */ |
| 152 | function logErrorImpl(error: Error): void { |
| 153 | const errorStr = error.stack || error.message |
| 154 | |
| 155 | // Enrich axios errors with request URL, status, and server message for debugging |
| 156 | let context = '' |
| 157 | if (axios.isAxiosError(error) && error.config?.url) { |
| 158 | const parts = [`url=${error.config.url}`] |
| 159 | if (error.response?.status !== undefined) { |
| 160 | parts.push(`status=${error.response.status}`) |
| 161 | } |
| 162 | const serverMessage = extractServerMessage(error.response?.data) |
| 163 | if (serverMessage) { |
| 164 | parts.push(`body=${serverMessage}`) |
| 165 | } |
| 166 | context = `[${parts.join(',')}] ` |
| 167 | } |
| 168 | |
| 169 | logForDebugging(`${error.name}: ${context}${errorStr}`, { level: 'error' }) |
| 170 | |
| 171 | appendToLog(getErrorsPath(), { |
| 172 | error: `${context}${errorStr}`, |
| 173 | }) |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Implementation for logMCPError - writes MCP error to debug log and file. |
nothing calls this directly
no test coverage detected