axios+telemetry cleanup
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* log.ts has NO heavy dependencies - events are queued until this sink is attached.
|
||||
*/
|
||||
|
||||
import axios from 'axios'
|
||||
import { isHttpError } from './http.js'
|
||||
import { dirname, join } from 'path'
|
||||
import { getSessionId } from '../bootstrap/state.js'
|
||||
import { createBufferedWriter } from './bufferedWriter.js'
|
||||
@@ -152,18 +152,20 @@ function extractServerMessage(data: unknown): string | undefined {
|
||||
function logErrorImpl(error: Error): void {
|
||||
const errorStr = error.stack || error.message
|
||||
|
||||
// Enrich axios errors with request URL, status, and server message for debugging
|
||||
// Enrich HTTP errors with request URL, status, and server message for debugging
|
||||
let context = ''
|
||||
if (axios.isAxiosError(error) && error.config?.url) {
|
||||
const parts = [`url=${error.config.url}`]
|
||||
if (error.response?.status !== undefined) {
|
||||
parts.push(`status=${error.response.status}`)
|
||||
if (isHttpError(error) && error.message) {
|
||||
const parts: string[] = []
|
||||
if (error.status !== undefined) {
|
||||
parts.push(`status=${error.status}`)
|
||||
}
|
||||
const serverMessage = extractServerMessage(error.response?.data)
|
||||
const serverMessage = extractServerMessage(error.data)
|
||||
if (serverMessage) {
|
||||
parts.push(`body=${serverMessage}`)
|
||||
}
|
||||
context = `[${parts.join(',')}] `
|
||||
if (parts.length > 0) {
|
||||
context = `[${parts.join(',')}] `
|
||||
}
|
||||
}
|
||||
|
||||
logForDebugging(`${error.name}: ${context}${errorStr}`, { level: 'error' })
|
||||
|
||||
Reference in New Issue
Block a user