class Etcd::Error

Represents all etcd custom errors

Attributes

cause[R]
error_code[R]
index[R]

Public Class Methods

from_http_response(response) click to toggle source
# File lib/etcd/exceptions.rb, line 17
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
new(opts = {}) click to toggle source
Calls superclass method
# File lib/etcd/exceptions.rb, line 10
def initialize(opts = {})
  super(opts['message'])
  @cause = opts['cause']
  @index = opts['index']
  @error_code = opts['errorCode']
end

Public Instance Methods

inspect() click to toggle source
# File lib/etcd/exceptions.rb, line 25
def inspect
  "<#{self.class}: index:#{index}, code:#{error_code}, cause:'#{cause}'>"
end