Skip to content

Mail admins when exceptions occur

Daniel Clemente Laboreo requested to merge clemente/mail-admins into master

Enable sending e-mail to ADMINS on failure. This includes exceptions in huey tasks.

Done as part of https://tasks.opencraft.com/browse/OC-2044

JIRA tickets: None Discussions: None Dependencies: None Screenshots: None Sandbox URL: None Merge deadline: None

Testing instructions:

  1. Add ADMINS to settings.py, e.g. ADMINS=[("You","aaaaa@example.com")], or the equivalent syntax in .env (with lists instead of tuples, and everything surrounded by single quotes)
  2. Add to your .env:
DEBUG=false
ADMINS='["something@example.com"]'
ALLOWED_HOSTS='["localhost"]'
SERVER_EMAIL='something@example.com'
DEFAULT_FROM_EMAIL='something@example.com'
EMAIL_HOST='localhost'
  1. (You don't really need a mail server because Django will show the message in the console)
  2. In watch_pr/tasks.py, add a raise ValueError("something") inside the task
  3. make run
  4. After less than 2 minutes you'll see an exception raised and the e-mail it would be sent

Reviewers

  • TBD

Author concerns: None Settings: None

Merge request reports