Fix error flattening

pull/30/head
Raphaël Vinot 2016-08-26 18:22:41 +02:00
parent 5bf6f52301
commit aaaab590f5
1 changed files with 11 additions and 4 deletions

View File

@ -166,10 +166,17 @@ class PyMISP(object):
elif response.get('errors'): elif response.get('errors'):
if isinstance(response['errors'], dict): if isinstance(response['errors'], dict):
for where, errors in response['errors'].items(): for where, errors in response['errors'].items():
for e in errors: if isinstance(errors, dict):
for type_e, msgs in e.items(): for where, msg in errors.items():
for m in msgs: messages.append('Error in {}: {}'.format(where, msg))
messages.append('Error in {}: {}'.format(where, m)) else:
for e in errors:
if isinstance(e, str):
messages.append(e)
continue
for type_e, msgs in e.items():
for m in msgs:
messages.append('Error in {}: {}'.format(where, m))
return messages return messages
def _check_response(self, response): def _check_response(self, response):