Method: Etcd::Error.from_http_response

Defined in:
lib/etcd/exceptions.rb

.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