bots: Improve error handling of yoda bot when the service is unavailable.
Frequent 503 errors throw index error exceptions which is misleading to debug.
This commit is contained in:
parent
a58fae5cab
commit
1e84e2eb5e
|
@ -27,6 +27,9 @@ HELP_MESSAGE = '''
|
||||||
class ApiKeyError(Exception):
|
class ApiKeyError(Exception):
|
||||||
'''raise this when there is an error with the Mashape Api Key'''
|
'''raise this when there is an error with the Mashape Api Key'''
|
||||||
|
|
||||||
|
class ServiceUnavailableError(Exception):
|
||||||
|
'''raise this when the service is unavailable.'''
|
||||||
|
|
||||||
|
|
||||||
class YodaSpeakHandler(object):
|
class YodaSpeakHandler(object):
|
||||||
'''
|
'''
|
||||||
|
@ -67,6 +70,8 @@ class YodaSpeakHandler(object):
|
||||||
return response.text
|
return response.text
|
||||||
if response.status_code == 403:
|
if response.status_code == 403:
|
||||||
raise ApiKeyError
|
raise ApiKeyError
|
||||||
|
if response.status_code == 503:
|
||||||
|
raise ServiceUnavailableError
|
||||||
else:
|
else:
|
||||||
error_message = response.text['message']
|
error_message = response.text['message']
|
||||||
logging.error(error_message)
|
logging.error(error_message)
|
||||||
|
|
Loading…
Reference in a new issue