Exception: Io::Flow::V0::HttpClient::ServerError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, details, incoming = {}) ⇒ ServerError

Returns a new instance of ServerError.



20005
20006
20007
20008
20009
20010
20011
20012
20013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20005

def initialize(code, details, incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @code = HttpClient::Preconditions.assert_class('code', code, Integer)
  @details = HttpClient::Preconditions.assert_class('details', details, String)
  @body = HttpClient::Preconditions.assert_class_or_nil('body', opts.delete(:body), String)
  @uri = HttpClient::Preconditions.assert_class_or_nil('uri', opts.delete(:uri), String)
  HttpClient::Preconditions.assert_empty_opts(opts)
  super(self.message)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



20003
20004
20005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20003

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



20003
20004
20005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20003

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



20003
20004
20005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20003

def details
  @details
end

#uriObject (readonly)

Returns the value of attribute uri.



20003
20004
20005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20003

def uri
  @uri
end

Instance Method Details

#body_jsonObject



20023
20024
20025
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20023

def body_json
  @body ? JSON.parse(@body) : nil
end

#messageObject



20015
20016
20017
20018
20019
20020
20021
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20015

def message
  m = "%s %s" % [@code, @details]
  if @body
    m << ": %s" % @body
  end
  m
end