-
Notifications
You must be signed in to change notification settings - Fork 2
Save exception message when Notification breaks #13
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.9.10 on 2017-09-26 22:29 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('transmissions', '0004_auto_20161027_1149'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='notification', | ||
| name='exception', | ||
| field=models.TextField(blank=True, default=b''), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,8 @@ class Status(EnumDict): | |
|
|
||
| status = models.IntegerField(default=Status.CREATED) | ||
|
|
||
| exception = models.TextField(blank=True, default='') | ||
|
|
||
| @property | ||
| def data(self): | ||
| if not hasattr(self, '_data'): | ||
|
|
@@ -120,8 +122,9 @@ def send(self): | |
| self.delete() | ||
| except ChannelSendException: | ||
| self.status = self.Status.FAILED | ||
| except: | ||
| except Exception as e: | ||
| self.status = self.Status.BROKEN | ||
| self.exception = "{klass}: {message}".format(klass=e.__class__.__name__, message=str(e)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arguably, this could be done through a 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. |
||
| raise | ||
| finally: | ||
| if self.pk: | ||
|
|
||
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
Notificationmodel 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!