_exceptions.py
changeset 8190 2a3c1b787688
parent 6491 ee9a10b6620e
child 8265 9747ab9230ad
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    14 # details.
    14 # details.
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """Exceptions shared by different cubicweb packages.
    18 """Exceptions shared by different cubicweb packages."""
    19 
    19 
    20 
       
    21 """
       
    22 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    23 
    21 
    24 from yams import ValidationError
    22 from yams import ValidationError
    25 
    23 
    26 # abstract exceptions #########################################################
    24 # abstract exceptions #########################################################
   112     msg = 'No entity with eid %s in %s'
   110     msg = 'No entity with eid %s in %s'
   113 
   111 
   114 
   112 
   115 # registry exceptions #########################################################
   113 # registry exceptions #########################################################
   116 
   114 
   117 class RegistryException(CubicWebException):
   115 # pre 3.15 bw compat
   118     """raised when an unregistered view is called"""
   116 from logilab.common.registry import RegistryException, ObjectNotFound, NoSelectableObject
   119 
       
   120 class RegistryNotFound(RegistryException):
       
   121     """raised when an unknown registry is requested
       
   122 
       
   123     this is usually a programming/typo error...
       
   124     """
       
   125 
       
   126 class ObjectNotFound(RegistryException):
       
   127     """raised when an unregistered object is requested
       
   128 
       
   129     this may be a programming/typo or a misconfiguration error
       
   130     """
       
   131 
       
   132 class NoSelectableObject(RegistryException):
       
   133     """raised when no appobject is selectable for a given context."""
       
   134     def __init__(self, args, kwargs, appobjects):
       
   135         self.args = args
       
   136         self.kwargs = kwargs
       
   137         self.appobjects = appobjects
       
   138 
       
   139     def __str__(self):
       
   140         return ('args: %s, kwargs: %s\ncandidates: %s'
       
   141                 % (self.args, self.kwargs.keys(), self.appobjects))
       
   142 
       
   143 
   117 
   144 class UnknownProperty(RegistryException):
   118 class UnknownProperty(RegistryException):
   145     """property found in database but unknown in registry"""
   119     """property found in database but unknown in registry"""
   146 
   120 
   147 # query exception #############################################################
   121 # query exception #############################################################
   159 class ExecutionError(Exception):
   133 class ExecutionError(Exception):
   160     """server execution control error (already started, not running...)"""
   134     """server execution control error (already started, not running...)"""
   161 
   135 
   162 # pylint: disable=W0611
   136 # pylint: disable=W0611
   163 from logilab.common.clcommands import BadCommandUsage
   137 from logilab.common.clcommands import BadCommandUsage
       
   138