Improve errors flattening

pull/98/head
Raphaël Vinot 2017-07-15 20:35:00 +02:00
parent cd7f928382
commit c91849b468
1 changed files with 13 additions and 9 deletions

View File

@ -185,15 +185,19 @@ class PyMISP(object):
else: else:
messages.append('Error in {}: {}'.format(where, msg)) messages.append('Error in {}: {}'.format(where, msg))
else: else:
for e in errors: if isinstance(errors, list):
if not e: for e in errors:
continue if not e:
if isinstance(e, basestring): continue
messages.append(e) if isinstance(e, basestring):
continue messages.append(e)
for type_e, msgs in e.items(): continue
for m in msgs: for type_e, msgs in e.items():
messages.append('Error in {}: {}'.format(where, m)) for m in msgs:
messages.append('Error in {}: {}'.format(where, m))
else:
messages.append('{} ({})'.format(errors, where))
return messages return messages
def _check_response(self, response): def _check_response(self, response):