born05 / craft-sentry

Pushes Craft CMS errors to Sentry.
MIT License
10 stars 11 forks source link

Add the ability to supress specific exceptions #30

Closed jaymeh closed 5 months ago

jaymeh commented 1 year ago

There are times where I'd quite like to have more granular control over which exceptions are being logged into Sentry by my application. I'm, wondering if in the configuration for this module we could have the ability to add specific error classes to an array which are ignored.

This should be easy to achieve by tapping into the error handling function and adding an extra check to see if we should log that exception:

Event::on(
    ErrorHandler::class,
    ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
    function(ExceptionEvent $event) {
        $this->sentry->handleException($event->exception);
    }
);

I was sure at one point Laravel gave you that level of fine control but can't seem to find an example 🤔

Happy to submit a PR for this if you think it could be useful.

Thanks

roelvanhintum commented 5 months ago

Sorry, for the very late response. Added an ignoreErrors option in 3.0.0