Merge pull request #271 from remram44/dont-catch-streamer-errors
Don't mask TwythonStreamer exceptions
This commit is contained in:
commit
1db20c049e
1 changed files with 3 additions and 2 deletions
|
|
@ -139,14 +139,15 @@ class TwythonStreamer(object):
|
||||||
if is_py3:
|
if is_py3:
|
||||||
line = line.decode('utf-8')
|
line = line.decode('utf-8')
|
||||||
data = json.loads(line)
|
data = json.loads(line)
|
||||||
|
except ValueError: # pragma: no cover
|
||||||
|
self.on_error(response.status_code, 'Unable to decode response, not valid JSON.')
|
||||||
|
else:
|
||||||
if self.on_success(data): # pragma: no cover
|
if self.on_success(data): # pragma: no cover
|
||||||
for message_type in self.handlers:
|
for message_type in self.handlers:
|
||||||
if message_type in data:
|
if message_type in data:
|
||||||
handler = getattr(self, 'on_' + message_type, None)
|
handler = getattr(self, 'on_' + message_type, None)
|
||||||
if handler and callable(handler) and not handler(data.get(message_type)):
|
if handler and callable(handler) and not handler(data.get(message_type)):
|
||||||
break
|
break
|
||||||
except ValueError: # pragma: no cover
|
|
||||||
self.on_error(response.status_code, 'Unable to decode response, not valid JSON.')
|
|
||||||
|
|
||||||
response.close()
|
response.close()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue