Skip to content

Commit 00b8e8c

Browse files
authored
Merge pull request #23 from pck-ut-ud/DaktelaAutodialer
Remove re-raising caught exception from 'publish_message' methods
2 parents fce80f8 + 27e8f9b commit 00b8e8c

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

pymess/backend/dialer/daktela.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def _update_dialer_states(self, messages):
8484
)
8585
except Exception as ex:
8686
self.update_message(message, state=DialerMessage.STATE.ERROR, error=force_text(ex))
87-
raise ex
87+
# Do not re-raise caught exception. We do not know exact exception to catch so we catch them all
88+
# and log them into database. Re-raise exception causes transaction rollback (lost of information about
89+
# exception).
8890

8991
def publish_message(self, message):
9092
"""
@@ -128,4 +130,6 @@ def publish_message(self, message):
128130
)
129131
except Exception as ex:
130132
self.update_message(message, state=DialerMessage.STATE.ERROR, error=force_text(ex))
131-
raise ex
133+
# Do not re-raise caught exception. We do not know exact exception to catch so we catch them all
134+
# and log them into database. Re-raise exception causes transaction rollback (lost of information about
135+
# exception).

pymess/backend/emails/mandrill.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ def publish_message(self, message):
8383
extra_sender_data=extra_sender_data, error=error)
8484
except (mandrill.Error, JSONDecodeError, requests.exceptions.RequestException) as ex:
8585
self.update_message(message, state=EmailMessage.STATE.ERROR, error=force_text(ex))
86-
raise ex
86+
# Do not re-raise caught exception. Re-raise exception causes transaction rollback (lost of information
87+
# about exception).

pymess/backend/emails/smtp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ def publish_message(self, message):
3232
self.update_message(message, state=EmailMessage.STATE.SENT, sent_at=timezone.now())
3333
except Exception as ex:
3434
self.update_message(message, state=EmailMessage.STATE.ERROR, error=force_text(ex))
35-
raise ex
35+
# Do not re-raise caught exception. We do not know exact exception to catch so we catch them all
36+
# and log them into database. Re-raise exception causes transaction rollback (lost of information about
37+
# exception).

pymess/backend/sms/sns.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ def publish_message(self, message):
5454
self.update_message(message, state=OutputSMSMessage.STATE.SENT, sent_at=timezone.now())
5555
except Exception as ex:
5656
self.update_message(message, state=OutputSMSMessage.STATE.ERROR, error=force_text(ex))
57-
raise ex
57+
# Do not re-raise caught exception. We do not know exact exception to catch so we catch them all
58+
# and log them into database. Re-raise exception causes transaction rollback (lost of information about
59+
# exception).

pymess/backend/sms/twilio.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ def publish_message(self, message):
6868
)
6969
except Exception as ex:
7070
self.update_message(message, state=OutputSMSMessage.STATE.ERROR, error=force_text(ex))
71-
raise ex
71+
# Do not re-raise caught exception. We do not know exact exception to catch so we catch them all
72+
# and log them into database. Re-raise exception causes transaction rollback (lost of information about
73+
# exception).

0 commit comments

Comments
 (0)