mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	send_email: Use CommandError for user-facing command line errors.
This provides much nicer error output (not a traceback).
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.core.mail import EmailMultiAlternatives | from django.core.mail import EmailMultiAlternatives | ||||||
|  | from django.core.management import CommandError | ||||||
| from django.template import loader | from django.template import loader | ||||||
| from django.utils.timezone import now as timezone_now | from django.utils.timezone import now as timezone_now | ||||||
| from django.utils.translation import override as override_language | 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): | class EmailNotDeliveredException(Exception): | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
| class DoubledEmailArgumentException(Exception): | class DoubledEmailArgumentException(CommandError): | ||||||
|     def __init__(self, argument_name: str) -> None: |     def __init__(self, argument_name: str) -> None: | ||||||
|         msg = "Argument '%s' is ambiguously present in both options and email template." % ( |         msg = "Argument '%s' is ambiguously present in both options and email template." % ( | ||||||
|             argument_name) |             argument_name) | ||||||
|         super().__init__(msg) |         super().__init__(msg) | ||||||
|  |  | ||||||
| class NoEmailArgumentException(Exception): | class NoEmailArgumentException(CommandError): | ||||||
|     def __init__(self, argument_name: str) -> None: |     def __init__(self, argument_name: str) -> None: | ||||||
|         msg = "Argument '%s' is required in either options or email template." % ( |         msg = "Argument '%s' is required in either options or email template." % ( | ||||||
|             argument_name) |             argument_name) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user