# HG changeset patch # User Laurent Peuch # Date 1557967181 -7200 # Node ID 6b2a9f2889566e8a74a9de7519c87d7f3301d060 # Parent 3bf9002de48e65f708390d6eee60b526a2837e14 [autopep8] E302 - Add missing 2 blank lines diff -r 3bf9002de48e -r 6b2a9f288956 cubicweb/_exceptions.py --- a/cubicweb/_exceptions.py Thu May 16 02:39:40 2019 +0200 +++ b/cubicweb/_exceptions.py Thu May 16 02:39:41 2019 +0200 @@ -27,6 +27,7 @@ # abstract exceptions ######################################################### + class CubicWebException(Exception): """base class for cubicweb server exception""" msg = "" @@ -40,43 +41,54 @@ else: return u' '.join(str(arg) for arg in self.args) + class ConfigurationError(CubicWebException): """a misconfiguration error""" + class InternalError(CubicWebException): """base class for exceptions which should not occur""" + class SecurityError(CubicWebException): """base class for cubicweb server security exceptions""" + class RepositoryError(CubicWebException): """base class for repository exceptions""" + class SourceException(CubicWebException): """base class for source exceptions""" + class CubicWebRuntimeError(CubicWebException): """base class for runtime exceptions""" # repository exceptions ####################################################### + class ConnectionError(RepositoryError): """raised when a bad connection id is given or when an attempt to establish a connection failed """ + class AuthenticationError(ConnectionError): """raised when an attempt to establish a connection failed due to wrong connection information (login / password or other authentication token) """ + class BadConnectionId(ConnectionError): """raised when a bad connection id is given""" + class UnknownEid(RepositoryError): """the eid is not defined in the system tables""" msg = 'No entity with eid %s in the repository' + class UniqueTogetherError(RepositoryError): """raised when a unique_together constraint caused an IntegrityError""" @@ -122,12 +134,14 @@ except Exception as ex: return str(ex) + class Forbidden(SecurityError): """raised when a user tries to perform a forbidden action """ # source exceptions ########################################################### + class EidNotInSource(SourceException): """trying to access an object with a particular eid from a particular source has failed @@ -140,28 +154,34 @@ # pre 3.15 bw compat from logilab.common.registry import RegistryException, ObjectNotFound, NoSelectableObject + class UnknownProperty(RegistryException): """property found in database but unknown in registry""" # query exception ############################################################# + class QueryError(CubicWebRuntimeError): """a query try to do something it shouldn't""" + class NotAnEntity(CubicWebRuntimeError): """raised when get_entity is called for a column which doesn't contain a non final entity """ + class MultipleResultsError(CubicWebRuntimeError): """raised when ResultSet.one() is called on a resultset with multiple rows of multiple columns. """ + class NoResultError(CubicWebRuntimeError): """raised when no result is found but at least one is expected. """ + class UndoTransactionException(QueryError): """Raised when undoing a transaction could not be performed completely. @@ -193,6 +213,7 @@ # tools exceptions ############################################################ + class ExecutionError(Exception): """server execution control error (already started, not running...)""" diff -r 3bf9002de48e -r 6b2a9f288956 cubicweb/web/_exceptions.py --- a/cubicweb/web/_exceptions.py Thu May 16 02:39:40 2019 +0200 +++ b/cubicweb/web/_exceptions.py Thu May 16 02:39:41 2019 +0200 @@ -30,12 +30,14 @@ def __init__(self, response): self.response = response + class InvalidSession(CubicWebException): """raised when a session id is found but associated session is not found or invalid""" # Publish related exception + class PublishException(CubicWebException): """base class for publishing related exception""" @@ -43,6 +45,7 @@ self.status = kwargs.pop('status', http_client.OK) super(PublishException, self).__init__(*args, **kwargs) + class LogOut(PublishException): """raised to ask for deauthentication of a logged in user""" @@ -50,6 +53,7 @@ super(LogOut, self).__init__() self.url = url + class Redirect(PublishException): """raised to redirect the http request""" @@ -57,6 +61,7 @@ super(Redirect, self).__init__(status=status) self.location = location + class StatusResponse(PublishException): def __init__(self, status, content=''): @@ -68,6 +73,7 @@ # Publish related error + class RequestError(PublishException): """raised when a request can't be served because of a bad input""" @@ -83,6 +89,7 @@ kwargs.setdefault('status', http_client.BAD_REQUEST) super(NothingToEdit, self).__init__(*args, **kwargs) + class ProcessFormError(RequestError): """raised when posted data can't be processed by the corresponding field """ @@ -91,6 +98,7 @@ kwargs.setdefault('status', http_client.BAD_REQUEST) super(ProcessFormError, self).__init__(*args, **kwargs) + class NotFound(RequestError): """raised when something was not found. In most case, a 404 error should be returned""" @@ -99,6 +107,7 @@ kwargs.setdefault('status', http_client.NOT_FOUND) super(NotFound, self).__init__(*args, **kwargs) + class RemoteCallFailed(RequestError): """raised when a json remote call fails """