Sentry not logging errors in try-catch block

Hello,

I’m running into a small issue with using Sentry, I’m trying to use Sentry on a React web app we’re building.

I’ve gone through the integration stages and was able to log a few sample errors to test the integration. The issue I’m facing is with how Sentry tracks the errors - as I understand, If I were to handle the error myself within a try-catch block, Sentry will not log this error yes? (As Sentry says it will log “unhandled” exceptions).

Unfortunately I do need to invoke some custom actions where an error occurs. For example - I need to fire an function that notifies the user that an error occurred and that we’re not able to perform the action they wanted

Is there a workaround for this? Any solution you would suggest?

As far as I understand, you need to track the exception that you catch?
It should be simple, you can track errors everwhere you want with Sentry.captureException(err);

1 Like

Thanks @tril ! I will try that as well.

One other question, I am trying to set up Sentry using Segment - i.e. I use Segment to track the errors and forward that to Sentry (so I don’t actually have Sentry installed on my app), is it still possible to capture these exceptions from within the try-catch block in that instance? Or do I have to set up Sentry on my app to do so?

I’m really sorry, but unfortunately I don’t know. I don’t really know anything about React + Segment.
But basically I would have said now, you have to integrate Sentry anyway. Whether via a third-party library (is segment one?) Or directly, it doesn’t really matter as long as the Sentry JS SDK is used.
And then that should also work with Sentry.captureException().