Can Sentry catch network error (XHR or fetch) in browser?

Viewed 1853

I am currently integrating Sentry into an Angular web application. I am successfully reporting console.log / warn / error and exceptions in Sentry as "issue".

However, when a request to my server fails (HTTP 4XX or 5XX), Sentry totally ignores this error and does not send it.

I have tried all possible values for tracingOrigins.

Sentry.init({
    dsn: '******',
    integrations: [
        new CaptureConsole(),
        new Integrations.BrowserTracing({
            tracingOrigins: ['localhost', 'http://localhost:4646/api']
        })
    ],
    tracesSampleRate: 1.0,
    debug: true
});

What can I do ?

1 Answers

I think you'd want an instance of Sentry running on your server to capture backend errors. You'd probably want to set these up in Sentry as two different projects.

Alternatively, you could manually track them in your Angular app when you get the response back - something like Sentry.captureException(err);

Related