Add exception name

This commit is contained in:
Aitor Magán 2014-06-30 13:19:40 +02:00
parent 3af8917175
commit 6d780ac38e
2 changed files with 6 additions and 6 deletions

View File

@ -34,7 +34,7 @@ class AdquiredDatasetsController(base.BaseController):
# Parse the result using the parser set in the configuration
result = parser().parse_notification()
except Exception as e:
result = {'errors': [str(e)]}
result = {'errors': [type(e).__name__ + ': ' + str(e)]}
else:
result = {'errors': ['%s not configured' % PARSER_CONFIG_PROP]}

View File

@ -40,11 +40,11 @@ class ControllerTest(unittest.TestCase):
@parameterized.expand([
('', None, False, False, '{"errors": ["%s not configured"]}' % PARSER_CONFIG_PROP),
('INVALID_CLASS', None, False, False, '{"errors": ["list index out of range"]}'),
('INVALID.CLASS', None, False, False, '{"errors": ["list index out of range"]}'),
('valid.path', CLASS_NAME, False, False, '{"errors": ["%s"]}' % IMPORT_ERROR_MSG),
('valid.path', CLASS_NAME, False, True, '{"errors": ["%s"]}' % IMPORT_ERROR_MSG),
('valid.path', CLASS_NAME, True, False, '{"errors": ["%s"]}' % CLASS_NAME),
('INVALID_CLASS', None, False, False, '{"errors": ["IndexError: list index out of range"]}'),
('INVALID.CLASS', None, False, False, '{"errors": ["IndexError: list index out of range"]}'),
('valid.path', CLASS_NAME, False, False, '{"errors": ["ImportError: %s"]}' % IMPORT_ERROR_MSG),
('valid.path', CLASS_NAME, False, True, '{"errors": ["ImportError: %s"]}' % IMPORT_ERROR_MSG),
('valid.path', CLASS_NAME, True, False, '{"errors": ["AttributeError: %s"]}' % CLASS_NAME),
('valid.path', CLASS_NAME, True, True, None)
])