Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom ExceptionReporter #100

Open
errrken opened this issue Feb 24, 2021 · 3 comments
Open

Custom ExceptionReporter #100

errrken opened this issue Feb 24, 2021 · 3 comments

Comments

@errrken
Copy link

errrken commented Feb 24, 2021

Thanks for a great library.

It would be great if one could provide a custom ExceptionReporter. For example, I do not want to send data like settings and request_meta when exceptions happens. Right now I do:

class CustomExceptionReporter(debug.ExceptionReporter):

    def get_traceback_data(self):
        data = super().get_traceback_data()
        data.pop('settings', None)
        data.pop('request_meta', None)
        return data

and then override all of SlackExceptionHandler emit method just to change the ExceptionReporter class.

EDIT (lamby): Adding Markdown

@lamby
Copy link
Owner

lamby commented Feb 24, 2021

Just to confirm, an ExceptionReporter that sends a message to Slack?

@errrken
Copy link
Author

errrken commented Feb 24, 2021

@lamby Yes, so here:

reporter = ExceptionReporter(request, is_email=True, *exc_info)
it uses Django's ExceptionReporter.

So like a setting SLACK_EXCEPTION_REPORTER or something where you can reference your own if you want to (like my CustomExceptionReporter above). My aim is to filter out unnecessary sensitive data like request metadata etc when an exception occurs and posting to slack.

Or maybe there is a better way?

@lamby
Copy link
Owner

lamby commented Feb 25, 2021

Not sure why you would need a SLACK_EXCEPTION_REPORTER setting to do that. Could you not subclass django_slack.log.SlackExceptionHandler (and modify its behaviour as you wish) and then configure your settings.LOGGING to point to that version instead? I think I might be missing something here, though; it's been a long time since I used this exception handler.

stianjensen added a commit to stianjensen/django-slack that referenced this issue Sep 1, 2022
As of Django 3.1 it is possible to override which exception report to
use:
https://docs.djangoproject.com/en/4.1/releases/3.1/#error-reporting

Relevant issue:
lamby#100
lamby pushed a commit that referenced this issue Sep 2, 2022
As of Django 3.1 it is possible to override which exception report to
use:
https://docs.djangoproject.com/en/4.1/releases/3.1/#error-reporting

Relevant issue:
#100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants