Class: Neo4j::Driver::Bolt::Message::Failure
- Inherits:
-
Object
- Object
- Neo4j::Driver::Bolt::Message::Failure
- Defined in:
- lib/neo4j/driver/bolt/message/failure.rb
Overview
Failure response from Neo4j server.
Two wire shapes, both handled by #to_exception:
* Legacy (pre-Bolt 5.7): { code:, message: }.
* GQL (Bolt 5.7+): { gql_status:, description:, message:, neo4j_code:,
diagnostic_record:, cause: } — `cause` nests the same shape.
Since the driver speaks 5.7, a legacy failure is synthesised into the GQL shape (gql_status 50N42, default diagnostic record) so the exception exposes the same fields regardless of the server's protocol version — matching the Java driver's GqlStatusException behaviour.
Constant Summary collapse
- EXCEPTION_FOR_CODE =
Code-prefix → driver exception class. Order matters: more specific patterns must come first.
[ [/^Neo\.ClientError\.Security\.Unauthorized/, Exceptions::AuthenticationException], [/^Neo\.ClientError\.Security\.AuthorizationExpired/, Exceptions::AuthorizationExpiredException], [/^Neo\.ClientError\.Security\.TokenExpired/, Exceptions::TokenExpiredException], [/^Neo\.ClientError\.Security/, Exceptions::SecurityException], [/^Neo\.ClientError\.Database\.DatabaseNotFound/, Exceptions::FatalDiscoveryException], [/^Neo\.ClientError/, Exceptions::ClientException], [/^Neo\.TransientError/, Exceptions::TransientException], [/^Neo\.DatabaseError/, Exceptions::DatabaseException] ].freeze
- CODE_REWRITES =
Two
TransientErrorcodes the server may send that are actually non-retryable: the driver rewrites them to theirClientErrorform (so they map to a non-retryable ClientException, not a retryable TransientException) and surfaces the rewritten code. Mirrors the Java driver's ErrorUtil special-case; testkit's test_should_not_retry_non_retryable_tx_failures asserts both the rewritten code and that the managed-tx executor does not retry. { 'Neo.TransientError.Transaction.Terminated' => 'Neo.ClientError.Transaction.Terminated', 'Neo.TransientError.Transaction.LockClientStopped' => 'Neo.ClientError.Transaction.LockClientStopped' }.freeze
- DEFAULT_DIAGNOSTIC_RECORD =
GQL diagnostic-record keys the server may omit; filled with these defaults so the record is always complete (mirrors the Java driver).
{ OPERATION: '', OPERATION_CODE: '0', CURRENT_SCHEMA: '/' }.freeze
- DEFAULT_GQL_STATUS =
Fallback GQL status for a legacy (non-GQL) failure: 50N42 = "general processing exception - unexpected error".
'50N42'- DEFAULT_STATUS_DESCRIPTION_PREFIX =
'error: general processing exception - unexpected error. '- KNOWN_CLASSIFICATIONS =
Diagnostic-record classifications the spec recognises; anything else (or absent) surfaces as the catch-all UNKNOWN.
%w[CLIENT_ERROR DATABASE_ERROR TRANSIENT_ERROR].freeze
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #assert_success! ⇒ Object
- #code ⇒ Object
-
#initialize(metadata) ⇒ Failure
constructor
A new instance of Failure.
- #message ⇒ Object
- #terminal? ⇒ Boolean
-
#to_exception ⇒ Object
Map this server FAILURE to its driver-side exception.
Constructor Details
#initialize(metadata) ⇒ Failure
Returns a new instance of Failure.
58 59 60 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 58 def initialize() @metadata = end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
56 57 58 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 56 def @metadata end |
Instance Method Details
#accept(visitor) ⇒ Object
76 77 78 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 76 def accept(visitor) visitor.on_failure(self) end |
#assert_success! ⇒ Object
80 81 82 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 80 def assert_success! raise to_exception end |
#code ⇒ Object
62 63 64 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 62 def code @metadata[:neo4j_code] || @metadata[:code] end |
#message ⇒ Object
66 67 68 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 66 def @metadata[:message] end |
#terminal? ⇒ Boolean
84 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 84 def terminal? = true |
#to_exception ⇒ Object
Map this server FAILURE to its driver-side exception. Single owner of the code→exception logic — used to live in 4+ places.
72 73 74 |
# File 'lib/neo4j/driver/bolt/message/failure.rb', line 72 def to_exception gql?(@metadata) ? build_gql(@metadata) : build_legacy(@metadata) end |