From e1849b63c14f909bb81ff366876d427325756dbd Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 18 Apr 2020 13:30:03 -0700 Subject: [PATCH] send_email: Use CommandError for user-facing command line errors. This provides much nicer error output (not a traceback). --- zerver/lib/send_email.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py index ee149c1164..97c75b139a 100644 --- a/zerver/lib/send_email.py +++ b/zerver/lib/send_email.py @@ -1,5 +1,6 @@ from django.conf import settings from django.core.mail import EmailMultiAlternatives +from django.core.management import CommandError from django.template import loader from django.utils.timezone import now as timezone_now from django.utils.translation import override as override_language @@ -130,13 +131,13 @@ def build_email(template_prefix: str, to_user_ids: Optional[List[int]]=None, class EmailNotDeliveredException(Exception): pass -class DoubledEmailArgumentException(Exception): +class DoubledEmailArgumentException(CommandError): def __init__(self, argument_name: str) -> None: msg = "Argument '%s' is ambiguously present in both options and email template." % ( argument_name) super().__init__(msg) -class NoEmailArgumentException(Exception): +class NoEmailArgumentException(CommandError): def __init__(self, argument_name: str) -> None: msg = "Argument '%s' is required in either options or email template." % ( argument_name)