Files
dyolink/frontend/src/lib/error-tracking/reportUnexpectedApiFailure.ts

21 lines
543 B
TypeScript
Raw Normal View History

import * as Sentry from '@sentry/nextjs';
import type { AxiosError } from 'axios';
/** Report network failures and HTTP 5xx only — not coded 4xx AppExceptions. */
export function reportUnexpectedApiFailure(error: AxiosError): void {
const status = error.response?.status;
if (status !== undefined && status < 500) {
return;
}
Sentry.captureException(error, {
tags: {
api_status: status ? String(status) : 'network',
},
extra: {
url: error.config?.url,
method: error.config?.method,
},
});
}