More Python client weirdness

There’s some weird interaction between the message attribute of the
exception and mocking.

Luckily there is an internal attribute – `_message` which doesn’t go
through all the magic.
This commit is contained in:
Chris Hill-Scott
2017-07-26 10:46:39 +01:00
parent 9f9c2d5e87
commit 68a1426e58

View File

@@ -668,11 +668,11 @@ def _check_notification(service_id, template_id, exception=None):
def get_template_error_dict(exception):
# TODO: Make API return some computer-friendly identifier as well as the end user error messages
if 'service is in trial mode' in exception.message:
if 'service is in trial mode' in exception._message:
error = 'not-allowed-to-send-to'
elif 'Exceeded send limits' in exception.message:
elif 'Exceeded send limits' in exception._message:
error = 'too-many-messages'
elif 'Content for template has a character count greater than the limit of' in exception.message:
elif 'Content for template has a character count greater than the limit of' in exception._message:
error = 'message-too-long'
else:
raise exception