diff --git a/src/telemetry/applicationInsights.ts b/src/telemetry/applicationInsights.ts index 3ebf7ee..7af3b45 100644 --- a/src/telemetry/applicationInsights.ts +++ b/src/telemetry/applicationInsights.ts @@ -106,7 +106,7 @@ export function trackException(error: any, context?: string): void { return; } - if (error instanceof AxiosError) { + if (error.isAxiosError) { trackHttpError(error, context); return; } diff --git a/src/utils/errorHandler.ts b/src/utils/errorHandler.ts index 1597080..da78aa8 100644 --- a/src/utils/errorHandler.ts +++ b/src/utils/errorHandler.ts @@ -68,12 +68,24 @@ export const handleMcpToolError = ( } // Handle network or other HTTP errors - if (error?.response) { + if (error.isAxiosError) { + if (error.response) { + return { + content: [ + { + type: "text", + text: `${contextPrefix}HTTP Error ${error?.response?.status}: ${error?.response?.statusText || "Unknown HTTP error"}\n\nResponse: ${JSON.stringify(error?.response?.data)}`, + }, + ], + isError: true, + }; + } + return { content: [ { type: "text", - text: `${contextPrefix}HTTP Error ${error.response.status}: ${error.response.statusText || "Unknown HTTP error"}\n\nResponse: ${JSON.stringify(error.response.data)}`, + text: `${contextPrefix}HTTP Error ${error.message}`, }, ], isError: true,