event_queue: Improve error message for ConnectionError exception

Improve error message for "ConnectionError:
HTTPConnectionPool(host='localhost', port=9993): Max retries
exceeded" exception.

Fixes #215.
This commit is contained in:
Rafid Aslam 2016-12-18 17:35:36 +07:00 committed by Tim Abbott
parent 7f7cae332b
commit e49bd6a6c7
1 changed files with 13 additions and 4 deletions

View File

@ -573,10 +573,19 @@ def request_event_queue(user_profile, user_client, apply_markdown,
'lifespan_secs': queue_lifespan_secs} 'lifespan_secs': queue_lifespan_secs}
if event_types is not None: if event_types is not None:
req['event_types'] = ujson.dumps(event_types) req['event_types'] = ujson.dumps(event_types)
try:
resp = requests_client.get(settings.TORNADO_SERVER + '/api/v1/events', resp = requests_client.get(settings.TORNADO_SERVER + '/api/v1/events',
auth=requests.auth.HTTPBasicAuth( auth=requests.auth.HTTPBasicAuth(
user_profile.email, user_profile.api_key), user_profile.email, user_profile.api_key),
params=req) params=req)
except requests.adapters.ConnectionError:
logging.error('Tornado server does not seem to be running, check %s '
'and %s for more information.' %
(settings.ERROR_FILE_LOG_PATH, "tornado.log"))
raise requests.adapters.ConnectionError(
"Django cannot connect to Tornado server (%s); try restarting" %
(settings.TORNADO_SERVER))
resp.raise_for_status() resp.raise_for_status()