Ignoring exceptions in Raven for Python

I want to ignore some of the exceptions my code generates as they are expected and only used to show proper message to the user afterwards.

It looks like the ignore_exceptions option is what I need, but as it is undocumented I was wondering if there is some caveats to using it that I should be aware of?

Edit: actually if there is a way to suppress exception logging from specific method it might be even better.

Edit: actually if there is a way to suppress exception logging from specific method it might be even better.

I’ve realized that just having this part wrapped with try/except is enough. But I do want to log those exceptions, so I just need to figure out how to avoid this specific logger being logged (remove the handler?).

I also have a similar issue on PHP. All my ValidationExceptions are being sent to Sentry, and it seems there’s no reliable way to ignore all of them because there are many different ValidationException messages :stuck_out_tongue:

Would be cool if we could see or edit ignored exceptions on the UI - so we could set it to ignore any exception with the name X or containing Y text…

EDIT: I managed to manually ignore exceptions by using the sendCallback; not the prettiest solution as this is present in other SDKs, but it does work:

$raven->setSendCallback(function(array &$data) use ($raven) {
    //skips any ValidationException errors. Comment this to easily test Sentry reports from any invalid request
    if (sizeof($data['exception']['values']) && $data['exception']['values'][0]['type'] == ValidationException::class) {
        return false;
    }
});
1 Like

Didn’t find it right away, but you can define exceptions to be ignored in the client definition.
https://raven.readthedocs.io/en/stable/advanced.html

ignore_exceptions = [
    'Http404',
    'django.exceptions.http.Http404',
    'django.exceptions.*',
]`