Class Neo4jException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ClientException, DatabaseException, DiscoveryException, ProtocolException, ServiceUnavailableException, SessionExpiredException, TransientException

public class Neo4jException extends RuntimeException
This is the base class for Neo4j exceptions.
Since:
1.0
See Also:
  • Constructor Details

    • Neo4jException

      public Neo4jException(String message)
      Creates a new instance.
      Parameters:
      message - the message
    • Neo4jException

      public Neo4jException(String message, Throwable cause)
      Creates a new instance.
      Parameters:
      message - the message
      cause - the cause
    • Neo4jException

      public Neo4jException(String code, String message)
      Creates a new instance.
      Parameters:
      code - the code
      message - the message
    • Neo4jException

      public Neo4jException(String code, String message, Throwable cause)
      Creates a new instance.
      Parameters:
      code - the code
      message - the message
      cause - the cause
    • Neo4jException

      public Neo4jException(String gqlStatus, String statusDescription, String code, String message, Map<String,Value> diagnosticRecord, Throwable cause)
      Creates a new instance.
      Parameters:
      gqlStatus - the GQLSTATUS as defined by the GQL standard
      statusDescription - the status description
      code - the code
      message - the message
      diagnosticRecord - the diagnostic record
      cause - the cause
      Since:
      5.26.0
  • Method Details

    • code

      public String code()
      Access the status code for this exception. The Neo4j manual can provide further details on the available codes and their meanings.
      Returns:
      textual code, such as "Neo.ClientError.Procedure.ProcedureNotFound"
    • gqlStatus

      public String gqlStatus()
      Returns the GQLSTATUS as defined by the GQL standard.
      Returns:
      the GQLSTATUS value
      Since:
      5.26.0
    • statusDescription

      public String statusDescription()
      Returns the GQLSTATUS description.
      Returns:
      the GQLSTATUS description
      Since:
      5.26.0
    • diagnosticRecord

      public Map<String,Value> diagnosticRecord()
      Returns the GQL diagnostic record.
      Returns:
      the GQL diagnostic record
      Since:
      5.26.0
    • classification

      public Optional<GqlStatusErrorClassification> classification()
      Returns the error classification as a GqlStatusErrorClassification enum value.

      The enum value is parsed using the rawClassification() value. Optional.empty() is returned if the String value is missing or is unknown.

      Returns:
      an Optional error classification as a GqlStatusErrorClassification enum value
      Since:
      5.26.0
      See Also:
    • rawClassification

      public Optional<String> rawClassification()
      Returns the error classification as a String value.

      The value is extracted from the diagnosticRecord() map using "_classification" key and is expected to be of TypeSystem.STRING() type. Optional.empty() is returned if the value is missing or is of different type.

      Returns:
      an Optional error classification as a raw String
      Since:
      5.26.0
      See Also:
    • gqlCause

      public Optional<Neo4jException> gqlCause()
      Returns the GQL error cause.
      Returns:
      an Optional of GQL error cause
      Since:
      5.26.0
    • containsGqlStatus

      public boolean containsGqlStatus(String gqlStatus)
      Returns whether there is an error with the given GQLSTATUS in this GQL error chain, beginning the search from this exception.
      Parameters:
      gqlStatus - the GQLSTATUS
      Returns:
      true if yes or false otherwise
      Since:
      5.28.8
    • findByGqlStatus

      public Optional<Neo4jException> findByGqlStatus(String gqlStatus)
      Finds the first Neo4jException that has the given GQLSTATUS in this GQL error chain, beginning the search from this exception.
      Parameters:
      gqlStatus - the GQLSTATUS
      Returns:
      an Optional of Neo4jException or Optional.empty() otherwise
      Since:
      5.28.8