diff --git a/ckan/exceptions.py b/ckan/exceptions.py index 5bcc92491e6..bd0d009e892 100644 --- a/ckan/exceptions.py +++ b/ckan/exceptions.py @@ -1,12 +1,16 @@ +# -*- coding: utf-8 -*- class CkanException(Exception): pass + class EmptyRevisionException(CkanException): pass + class CkanUrlException(Exception): pass + class CkanVersionException(Exception): '''Exception raised by :py:func:`~ckan.plugins.toolkit.requires_ckan_version` if the required CKAN @@ -15,5 +19,14 @@ class CkanVersionException(Exception): ''' pass + class CkanConfigurationException(Exception): pass + + +class HelperError(Exception): + """Raised if an attempt to access an undefined helper is made. + + Normally, this would be a subclass of AttributeError, but Jinja2 will + catch and ignore them. We want this to be an explicit failure re #2908. + """ diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 1394a53d1bf..514f46dcab5 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -50,14 +50,6 @@ log = logging.getLogger(__name__) -class HelperError(Exception): - """Raised if an attempt to access an undefined helper is made. - - Normally, this would be a subclass of AttributeError, but Jinja2 will - catch and ignore them. We want this to be an explicit failure re #2908. - """ - - class AttributeDict(dict): def __init__(self, *args, **kwargs): super(AttributeDict, self).__init__(*args, **kwargs) @@ -67,7 +59,7 @@ def __getitem__(self, key): try: value = super(AttributeDict, self).__getitem__(self, key) except AttributeError: - raise HelperError( + raise ckan.exceptions.HelperError( 'Helper \'{key}\' has not been defined.'.format( key=key )