Skip to content

Commit 4d0b1fb

Browse files
committed
slightly improved error messages for input exceptions
1 parent e2f8ebf commit 4d0b1fb

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎stream/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__copyright__ = 'Copyright 2012, Thierry Schellenbach'
55
__credits__ = ['Thierry Schellenbach, mellowmorning.com, @tschellenbach']
66
__license__ = 'BSD'
7-
__version__ = '0.2.10'
7+
__version__ = '0.2.11'
88
__maintainer__ = 'Thierry Schellenbach'
99
__email__ = 'thierryschellenbach@gmail.com'
1010
__status__ = 'Production'

‎stream/client.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ def raise_exception(self, result, status_code):
9494
'''
9595
from stream.exceptions import get_exception_dict
9696
error_message = result['detail']
97+
exception_fields = result.get('exception_fields')
98+
if exception_fields:
99+
errors = []
100+
for field, errors in exception_fields.items():
101+
errors.append('Field "%s" errors: %s' % (field, ','.join(errors)))
102+
error_message = '\n'.join(errors)
97103
error_code = result.get('code')
98104
exception_dict = get_exception_dict()
99105
exception_class = exception_dict.get(

‎stream/tests.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ def test_missing_field_exception(self):
157157
def test_missing_actor(self):
158158
activity_data = {'verb': 'tweet', 'object':
159159
1, 'debug_example_undefined': 'test'}
160-
self.assertRaises(InputException, lambda:
161-
self.user1.add_activity(activity_data))
160+
doit = lambda: self.user1.add_activity(activity_data)
161+
try:
162+
doit()
163+
raise ValueError('should have raised InputException')
164+
except InputException as e:
165+
pass
162166

163167
def test_wrong_feed_spec(self):
164168
self.c = stream.connect(

0 commit comments

Comments
 (0)