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:
messages.append('Error in {}: {}'.format(where, msg))
else:
for e in errors:
if not e:
continue
if isinstance(e, basestring):
messages.append(e)
continue
for type_e, msgs in e.items():
for m in msgs:
messages.append('Error in {}: {}'.format(where, m))
if isinstance(errors, list):
for e in errors:
if not e:
continue
if isinstance(e, basestring):
messages.append(e)
continue
for type_e, msgs in e.items():
for m in msgs:
messages.append('Error in {}: {}'.format(where, m))
else:
messages.append('{} ({})'.format(errors, where))
return messages
def _check_response(self, response):