diff --git a/docs/source/api.rst b/docs/source/api.rst index cd4c598c5..cd8bc421c 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -1233,22 +1233,39 @@ Errors Neo4j Errors ============ -Neo4j Execution Errors +Server-side errors * :class:`neo4j.exceptions.Neo4jError` * :class:`neo4j.exceptions.ClientError` + * :class:`neo4j.exceptions.CypherSyntaxError` + + * :class:`neo4j.exceptions.CypherTypeError` + + * :class:`neo4j.exceptions.ConstraintError` + + * :class:`neo4j.exceptions.AuthError` + + * :class:`neo4j.exceptions.TokenExpired` + + * :class:`neo4j.exceptions.Forbidden` + * :class:`neo4j.exceptions.DatabaseError` * :class:`neo4j.exceptions.TransientError` + * :class:`neo4j.exceptions.DatabaseUnavailable` + + * :class:`neo4j.exceptions.NotALeader` + + * :class:`neo4j.exceptions.ForbiddenOnReadOnlyDatabase` + .. autoclass:: neo4j.exceptions.Neo4jError :members: message, code, is_retriable, is_retryable - .. autoclass:: neo4j.exceptions.ClientError :show-inheritance: @@ -1264,13 +1281,10 @@ Neo4j Execution Errors .. autoclass:: neo4j.exceptions.AuthError :show-inheritance: -.. autoclass:: neo4j.exceptions.Forbidden +.. autoclass:: neo4j.exceptions.TokenExpired :show-inheritance: -.. autoclass:: neo4j.exceptions.ForbiddenOnReadOnlyDatabase - :show-inheritance: - -.. autoclass:: neo4j.exceptions.NotALeader +.. autoclass:: neo4j.exceptions.Forbidden :show-inheritance: .. autoclass:: neo4j.exceptions.DatabaseError @@ -1282,25 +1296,50 @@ Neo4j Execution Errors .. autoclass:: neo4j.exceptions.DatabaseUnavailable :show-inheritance: +.. autoclass:: neo4j.exceptions.NotALeader + :show-inheritance: + +.. autoclass:: neo4j.exceptions.ForbiddenOnReadOnlyDatabase + :show-inheritance: + + Driver Errors ============= -Connectivity Errors +Client-side errors * :class:`neo4j.exceptions.DriverError` * :class:`neo4j.exceptions.TransactionError` + * :class:`neo4j.exceptions.TransactionNestingError` + + * :class:`neo4j.exceptions.ResultError` + + * :class:`neo4j.exceptions.ResultConsumedError` + + * :class:`neo4j.exceptions.ResultNotSingleError` + * :class:`neo4j.exceptions.SessionExpired` * :class:`neo4j.exceptions.ServiceUnavailable` + * :class:`neo4j.exceptions.RoutingServiceUnavailable` + + * :class:`neo4j.exceptions.WriteServiceUnavailable` + + * :class:`neo4j.exceptions.ReadServiceUnavailable` + + * :class:`neo4j.exceptions.IncompleteCommit` + * :class:`neo4j.exceptions.ConfigurationError` - * :class:`neo4j.exceptions.ResultConsumedError` + * :class:`neo4j.exceptions.AuthConfigurationError` + + * :class:`neo4j.exceptions.CertificateConfigurationError` .. autoclass:: neo4j.exceptions.DriverError @@ -1312,15 +1351,21 @@ Connectivity Errors .. autoclass:: neo4j.exceptions.TransactionNestingError :show-inheritance: +.. autoclass:: neo4j.exceptions.ResultError + :show-inheritance: + +.. autoclass:: neo4j.exceptions.ResultConsumedError + :show-inheritance: + +.. autoclass:: neo4j.exceptions.ResultNotSingleError + :show-inheritance: + .. autoclass:: neo4j.exceptions.SessionExpired :show-inheritance: .. autoclass:: neo4j.exceptions.ServiceUnavailable :show-inheritance: - Raised when a database server or service is not available. - This may be due to incorrect configuration or could indicate a runtime failure of a database service that the driver is unable to route around. - .. autoclass:: neo4j.exceptions.RoutingServiceUnavailable :show-inheritance: @@ -1330,6 +1375,9 @@ Connectivity Errors .. autoclass:: neo4j.exceptions.ReadServiceUnavailable :show-inheritance: +.. autoclass:: neo4j.exceptions.IncompleteCommit + :show-inheritance: + .. autoclass:: neo4j.exceptions.ConfigurationError :show-inheritance: @@ -1339,12 +1387,6 @@ Connectivity Errors .. autoclass:: neo4j.exceptions.CertificateConfigurationError :show-inheritance: -.. autoclass:: neo4j.exceptions.ResultConsumedError - :show-inheritance: - -.. autoclass:: neo4j.exceptions.ResultNotSingleError - :show-inheritance: - Internal Driver Errors diff --git a/neo4j/exceptions.py b/neo4j/exceptions.py index 1446fcfc5..36ba00958 100644 --- a/neo4j/exceptions.py +++ b/neo4j/exceptions.py @@ -95,6 +95,7 @@ } +# Neo4jError class Neo4jError(Exception): """ Raised when the Cypher engine returns an error to the client. """ @@ -215,70 +216,82 @@ def __str__(self): return "{{code: {code}}} {{message: {message}}}".format(code=self.code, message=self.message) +# Neo4jError > ClientError class ClientError(Neo4jError): """ The Client sent a bad request - changing the request might yield a successful outcome. """ def __str__(self): - return super(Neo4jError, self).__str__() + return super().__str__() -class DatabaseError(Neo4jError): - """ The database failed to service the request. +# Neo4jError > ClientError > CypherSyntaxError +class CypherSyntaxError(ClientError): """ - - -class TransientError(Neo4jError): - """ The database cannot service the request right now, retrying later might yield a successful outcome. """ - def is_retryable(self): - return True - -class DatabaseUnavailable(TransientError): +# Neo4jError > ClientError > CypherTypeError +class CypherTypeError(ClientError): """ """ +# Neo4jError > ClientError > ConstraintError class ConstraintError(ClientError): """ """ -class CypherSyntaxError(ClientError): - """ +# Neo4jError > ClientError > AuthError +class AuthError(ClientError): + """ Raised when authentication failure occurs. """ -class CypherTypeError(ClientError): - """ +# Neo4jError > ClientError > AuthError > TokenExpired +class TokenExpired(AuthError): + """ Raised when the authentication token has expired. + + A new driver instance with a fresh authentication token needs to be created. """ -class NotALeader(TransientError): +# Neo4jError > ClientError > Forbidden +class Forbidden(ClientError): """ """ -class Forbidden(ClientError): +# Neo4jError > DatabaseError +class DatabaseError(Neo4jError): + """ The database failed to service the request. """ + + +# Neo4jError > TransientError +class TransientError(Neo4jError): + """ The database cannot service the request right now, retrying later might yield a successful outcome. """ + def is_retryable(self): + return True -class ForbiddenOnReadOnlyDatabase(TransientError): + +# Neo4jError > TransientError > DatabaseUnavailable +class DatabaseUnavailable(TransientError): """ """ -class AuthError(ClientError): - """ Raised when authentication failure occurs. +# Neo4jError > TransientError > NotALeader +class NotALeader(TransientError): + """ """ -class TokenExpired(AuthError): - """ Raised when the authentication token has expired. - - A new driver instance with a fresh authentication token needs to be created. +# Neo4jError > TransientError > ForbiddenOnReadOnlyDatabase +class ForbiddenOnReadOnlyDatabase(TransientError): + """ """ @@ -325,6 +338,7 @@ class TokenExpired(AuthError): } +# DriverError class DriverError(Exception): """ Raised when the Driver raises an error. """ @@ -342,75 +356,89 @@ def is_retryable(self): return False -class SessionExpired(DriverError): - """ Raised when a session is no longer able to fulfil - the purpose described by its original parameters. - """ - - def __init__(self, session, *args, **kwargs): - super(SessionExpired, self).__init__(session, *args, **kwargs) - - def is_retryable(self): - return True - - +# DriverError > TransactionError class TransactionError(DriverError): """ Raised when an error occurs while using a transaction. """ def __init__(self, transaction, *args, **kwargs): - super(TransactionError, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.transaction = transaction -class TransactionNestingError(DriverError): +# DriverError > TransactionNestingError +class TransactionNestingError(TransactionError): """ Raised when transactions are nested incorrectly. """ def __init__(self, transaction, *args, **kwargs): - super(TransactionError, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.transaction = transaction +# DriverError > ResultError class ResultError(DriverError): """Raised when an error occurs while using a result object.""" def __init__(self, result, *args, **kwargs): - super(ResultError, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.result = result +# DriverError > ResultError > ResultConsumedError class ResultConsumedError(ResultError): """Raised when trying to access records of a consumed result.""" +# DriverError > ResultError > ResultNotSingleError class ResultNotSingleError(ResultError): """Raised when a result should have exactly one record but does not.""" +# DriverError > SessionExpired +class SessionExpired(DriverError): + """ Raised when a session is no longer able to fulfil + the purpose described by its original parameters. + """ + + def __init__(self, session, *args, **kwargs): + super().__init__(session, *args, **kwargs) + + def is_retryable(self): + return True + + +# DriverError > ServiceUnavailable class ServiceUnavailable(DriverError): """ Raised when no database service is available. + + This may be due to incorrect configuration or could indicate a runtime + failure of a database service that the driver is unable to route around. """ def is_retryable(self): return True +# DriverError > ServiceUnavailable > RoutingServiceUnavailable class RoutingServiceUnavailable(ServiceUnavailable): """ Raised when no routing service is available. """ +# DriverError > ServiceUnavailable > WriteServiceUnavailable class WriteServiceUnavailable(ServiceUnavailable): """ Raised when no write service is available. """ +# DriverError > ServiceUnavailable > ReadServiceUnavailable class ReadServiceUnavailable(ServiceUnavailable): """ Raised when no read service is available. """ +# DriverError > ServiceUnavailable > IncompleteCommit class IncompleteCommit(ServiceUnavailable): """ Raised when the client looses connection while committing a transaction @@ -424,16 +452,19 @@ def is_retryable(self): return False +# DriverError > ConfigurationError class ConfigurationError(DriverError): """ Raised when there is an error concerning a configuration. """ +# DriverError > ConfigurationError > AuthConfigurationError class AuthConfigurationError(ConfigurationError): """ Raised when there is an error with the authentication configuration. """ +# DriverError > ConfigurationError > CertificateConfigurationError class CertificateConfigurationError(ConfigurationError): """ Raised when there is an error with the authentication configuration. """