Exception: TriCoreDB::Error
- Inherits:
-
StandardError
- Object
- StandardError
- TriCoreDB::Error
- Defined in:
- lib/tricoredb/errors.rb
Overview
Base class for every failure raised by this gem.
Branch on #code, never on the message: the message is prose the server is free to reword, the code is contract.
Direct Known Subclasses
AuthError, ConnectionError, FeatureNotGranted, ParameterError, PoolTimeout, ProtocolError, ServerError
Instance Attribute Summary collapse
-
#code ⇒ String?
readonly
The machine-readable reason, when the server sent one.
-
#leader_hint ⇒ String?
readonly
A
host:portof the current leader, only alongsidenot_leader.
Instance Method Summary collapse
-
#initialize(message = nil, code: nil, leader_hint: nil) ⇒ Error
constructor
A new instance of Error.
-
#redirect? ⇒ Boolean
Whether the request was right but reached a node that is not the leader.
Constructor Details
#initialize(message = nil, code: nil, leader_hint: nil) ⇒ Error
Returns a new instance of Error.
20 21 22 23 24 |
# File 'lib/tricoredb/errors.rb', line 20 def initialize( = nil, code: nil, leader_hint: nil) super() @code = code @leader_hint = leader_hint end |
Instance Attribute Details
#code ⇒ String? (readonly)
Returns the machine-readable reason, when the server sent one.
13 14 15 |
# File 'lib/tricoredb/errors.rb', line 13 def code @code end |
#leader_hint ⇒ String? (readonly)
Returns a host:port of the current leader, only alongside not_leader.
15 16 17 |
# File 'lib/tricoredb/errors.rb', line 15 def leader_hint @leader_hint end |
Instance Method Details
#redirect? ⇒ Boolean
Whether the request was right but reached a node that is not the leader.
The driver never follows #leader_hint on its own: the address may not be reachable from this client, a new connection must authenticate again, and an open session transaction cannot move to another node at all.
33 34 35 |
# File 'lib/tricoredb/errors.rb', line 33 def redirect? code == NOT_LEADER end |