3.3 · Lesson

Error handling

When working with Neo4j, you may encounter various database errors that need to be handled gracefully in your application. The driver throws exceptions that inherit from Neo4jException for all database-related errors. Exceptions related to the driver and its connection are subclasses of ServiceUnavailableException.

  • ClientException —Raised when the Full definition for Cypher (opens in a new tab)Neo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. syntax is invalid or a Full definition for constraint (opens in a new tab)A rule the database enforces on every node or relationship with a given label or type, rejecting any write that breaks it. is violated
  • AuthenticationException —Raised when authentication fails
  • ServiceUnavailableException —Raised when the database is not accessible
  • TransientException —Raised for temporary failures that may succeed on retry