bug: Fix traceback in get_missed_message_token_from_address().

If you supplied an unrecognizable address to our email system,
or you had EMAIL_GATEWAY_PATTERN configured wrong,
the get_missed_message_token_from_address() used to crash
hard and cryptically with a traceback saying that you can't
call startswith() on a None object.

Now we throw a ZulipEmailForwardError exception.  This will
still lead to a traceback, but it should be easier to diagnose
the problem.
This commit is contained in:
Steve Howell
2016-09-22 09:55:18 -07:00
committed by Tim Abbott
parent dbbc64dbfe
commit f0eaee68e4
2 changed files with 11 additions and 0 deletions

View File

@@ -90,6 +90,9 @@ def get_missed_message_token_from_address(address):
# type: (text_type) -> text_type
msg_string = get_email_gateway_message_string_from_address(address)
if msg_string is None:
raise ZulipEmailForwardError('Address not recognized by gateway.')
if not is_mm_32_format(msg_string):
raise ZulipEmailForwardError('Could not parse missed message address')