From 6d780ac38efedb364f761eafffb1a886c7a1bb66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aitor=20Mag=C3=A1n?= Date: Mon, 30 Jun 2014 13:19:40 +0200 Subject: [PATCH] Add exception name --- ckanext/privatedatasets/controller.py | 2 +- ckanext/privatedatasets/tests/test_controller.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ckanext/privatedatasets/controller.py b/ckanext/privatedatasets/controller.py index 8ce96ea..15d6cd3 100644 --- a/ckanext/privatedatasets/controller.py +++ b/ckanext/privatedatasets/controller.py @@ -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]} diff --git a/ckanext/privatedatasets/tests/test_controller.py b/ckanext/privatedatasets/tests/test_controller.py index 32cb672..1f9fa49 100644 --- a/ckanext/privatedatasets/tests/test_controller.py +++ b/ckanext/privatedatasets/tests/test_controller.py @@ -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) ])