stages/email: improve error handling
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
0d370ef0a9
commit
83cfb5f8c2
|
@ -48,7 +48,12 @@ def send_mail(
|
|||
stage: EmailStage = EmailStage(use_global_settings=True)
|
||||
else:
|
||||
stage: EmailStage = EmailStage.objects.get(pk=email_stage_pk)
|
||||
try:
|
||||
backend = stage.backend
|
||||
except ValueError as exc:
|
||||
LOGGER.warning(exc)
|
||||
self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc))
|
||||
return
|
||||
backend.open()
|
||||
# Since django's EmailMessage objects are not JSON serialisable,
|
||||
# we need to rebuild them from a dict
|
||||
|
@ -68,7 +73,7 @@ def send_mail(
|
|||
messages=["Successfully sent Mail."],
|
||||
)
|
||||
)
|
||||
except (SMTPException, ConnectionError, ValueError) as exc:
|
||||
except (SMTPException, ConnectionError) as exc:
|
||||
LOGGER.debug("Error sending email, retrying...", exc=exc)
|
||||
self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc))
|
||||
raise exc
|
||||
|
|
Reference in a new issue