Skip to content
Advertisement

Sentry + Laravel: how to log an already catched Exception?

We’re using Laravel ( 5.x to 7.x ) in a lot of project and all integrated with Sentry.

In some edge case we need to catch some recoverable exceptions to allow page flow to go on using fallbacks, but we also would like to log these catched exception to sentry.

I cannot find a documented or undocumented way to manually log to Sentry.

Is there a way to log to sentry an already catched exception?

Advertisement

Answer

^ this is the way to do this.

If you want to use the Laravel container it could look more like this:

JavaScript

You can also report use which should also log the exception to your log files:

JavaScript

Also, you could manually use the Sentry’s helpers – the source code is here

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement