-
Notifications
You must be signed in to change notification settings - Fork 2
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
Save exception message when Notification breaks #13
base: master
Are you sure you want to change the base?
Conversation
6f2d9f6
to
466619f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pbaranay, happy to discuss my comments more
@@ -85,6 +85,8 @@ class Status(EnumDict): | |||
|
|||
status = models.IntegerField(default=Status.CREATED) | |||
|
|||
exception = models.TextField(blank=True, default='') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pbaranay! Unfortunately, the Notification
model is meant to be extremely lean since it's storing 100s of millions of entries in production.
I'd suggest moving this feature to separate table since most notifications shouldn't have any exception anyway!
self.status = self.Status.BROKEN | ||
self.exception = "{klass}: {message}".format(klass=e.__class__.__name__, message=str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably, this could be done through a logging
system rather than a permanent data store. I think logging
would be a more suitable solution to introduce here since it's only assuming you've configured Django for it right now.
Either way you will want to make it configurable with settings. Logging is controlled by logging routes in settings, but if you introduce a new model/field, please add a setting.
It would be very useful to see the text of the exception that's thrown when sending a notification breaks. Here's a pull request to add a field storing this information to the model. Please let me know what you think!