From c91849b4688109a2f7bf821b59517886c4244ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 15 Jul 2017 20:35:00 +0200 Subject: [PATCH] Improve errors flattening --- pymisp/api.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pymisp/api.py b/pymisp/api.py index d7da661..cf6bc9c 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -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):