Exception: Etcd::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Etcd::Error
- Defined in:
- lib/etcd/exceptions.rb
Overview
Represents all etcd custom errors
Direct Known Subclasses
DirNotEmpty, EventIndexCleared, IndexNaN, KeyIsPreserved, KeyNotFound, LeaderElect, NoMorePeer, NodeExist, NotDir, NotFile, PrevValueRequired, RaftInternal, TTLNaN, TestFailed, ValueRequired, WatcherCleared
Instance Attribute Summary collapse
-
#cause ⇒ Object
readonly
Returns the value of attribute cause.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Error
constructor
A new instance of Error.
- #inspect ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Error
Returns a new instance of Error.
11 12 13 14 15 16 |
# File 'lib/etcd/exceptions.rb', line 11 def initialize(opts = {}) super(opts['message']) @cause = opts['cause'] @index = opts['index'] @error_code = opts['errorCode'] end |
Instance Attribute Details
#cause ⇒ Object (readonly)
Returns the value of attribute cause.
9 10 11 |
# File 'lib/etcd/exceptions.rb', line 9 def cause @cause end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
9 10 11 |
# File 'lib/etcd/exceptions.rb', line 9 def error_code @error_code end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
9 10 11 |
# File 'lib/etcd/exceptions.rb', line 9 def index @index end |
Class Method Details
.from_http_response(response) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/etcd/exceptions.rb', line 18 def self.from_http_response(response) opts = JSON.parse(response.body) unless ERROR_CODE_MAPPING.key?(opts['errorCode']) fail "Unknown error code: #{opts['errorCode']}" end ERROR_CODE_MAPPING[opts['errorCode']].new(opts) end |
Instance Method Details
#inspect ⇒ Object
26 27 28 |
# File 'lib/etcd/exceptions.rb', line 26 def inspect "<#{self.class}: index:#{index}, code:#{error_code}, cause:'#{cause}'>" end |