I'm running into a very annoying issue where Sentry is somehow capturing caught exceptions.
Running Laravel 5.7 with sentry-laravel 1.0.0
How to replicate:
I've created a command to run on the prod server
$test = [1];
try {
echo $test[2];
} catch(\Exception $e) {
}
I run this, and it runs through just fine, as expected. The laravel.log is empty, as expected.
Yet a new issue pops up on Sentry

I'm kinda lost as to where this happens too. I've had a look at the Exceptions\Handler@report method, and it's never triggered either.
Maybe I've missed something new with v1?
Any help would be GREATLY appreciated. I'm currently drowning in issues!
Hey @JorgenSolli, I can explain, it's not a Sentry bug or issue actually.
A notice is not an exception, and can't be caught by a try/catch block.
A notice is an Error in PHP and captured by the error handler (which Sentry listens on).
There are a few things you can do to fix your code:
echo $test[2] ?? ''; (Null Coalescing Operator)echo isset($test[2]) ? $test[2] : '';The other option is to disable reporting notices in Sentry, but I would not recommend it since it's easier to guard against the notice being there in the first place.
Does this explain it enough?
Edit: I should explain why Sentry says ErrorException.
Since a notice generates an error and we have no definition of an error in Sentry we internally convert it to a ErrorException to be able to submit it to Sentry.
Hi, @stayallive
Thanks for taking the time to explain. Much appreciated! :)
The notices origins from a library I use, phpseclib/phpseclib, which sort of put things out of my control.
Guess I'll disable reporting notices for now.
Thanks again for your time
Regards
Ah yes, phpseclib is a bit of a pain in the arse with their trigger_error calls too which can't be caught in userland... bit of a pain of the legacy.
You can disable the notices by adding the following to your config/sentry.php:
'error_types' => E_ALL ^ E_NOTICE,
But keep in mind that disables the reporting of EVERY notice in you application.
You could look to implement some more advanced filtering to filter out notices emitted from phpseclib to prevent having to disable notice reporting: https://docs.sentry.io/error-reporting/configuration/filtering/?platform=php.
Most helpful comment
Hey @JorgenSolli, I can explain, it's not a Sentry bug or issue actually.
A notice is not an exception, and can't be caught by a try/catch block.
A notice is an Error in PHP and captured by the error handler (which Sentry listens on).
There are a few things you can do to fix your code:
echo $test[2] ?? '';(Null Coalescing Operator)echo isset($test[2]) ? $test[2] : '';The other option is to disable reporting notices in Sentry, but I would not recommend it since it's easier to guard against the notice being there in the first place.
Does this explain it enough?
Edit: I should explain why Sentry says ErrorException.
Since a notice generates an error and we have no definition of an error in Sentry we internally convert it to a ErrorException to be able to submit it to Sentry.