rollbar/pyrollbar

In django app, normal exceptions like PermissionDenied should not be reported to rollbar

brettdh opened this issue · 1 comments

A 403 response (e.g. due to an authenticated user visiting a URL they are not authorized to access) is an normal response and not indicative of an error in the app. However, the Rollbar middleware for Django reports this exception to Rollbar, and it's not clear to me how (or if) I can configure the middleware to suppress these kinds of spurious errors.

bxsx commented

Hi @brettdh and sorry for the late reply.

You can ignore exceptions with event handlers.

In your case, you may need a handler like this:

def ignore_403s_handler(payload, **kw):
    if payload['data']['body']['trace']['exception']['class'] == 'PermissionDenied':
        return False
    
    return payload

See docs for details: https://docs.rollbar.com/docs/python#ignoring-items