From 879de7549e930c1580cb3a90f4551fea62717e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Starck?= Date: Wed, 24 Feb 2016 16:34:50 -0500 Subject: [PATCH] Fixed a bare except AFAIK the only exception which can occur here is one that the json.loads(..) could raise. So (TypeError or) ValueError. So except on that. and also log a warning in such case. bare excepts are 99.99% of the time simply bad/wrong. It's the case here. --- elasticsearch/connection/base.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elasticsearch/connection/base.py b/elasticsearch/connection/base.py index 914967c3..82339345 100644 --- a/elasticsearch/connection/base.py +++ b/elasticsearch/connection/base.py @@ -101,9 +101,8 @@ class Connection(object): error_message = additional_info.get('error', error_message) if isinstance(error_message, dict) and 'type' in error_message: error_message = error_message['type'] - except: - # we don't care what went wrong - pass + except (ValueError, TypeError) as err: + logger.warning('Undecodable raw error response from server: %s', err) raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)