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.



23135
23136
23137
23138
23139
23140
23141
23142
23143
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23135

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

#body ⇒ Object (readonly)

Returns the value of attribute body.



23133
23134
23135
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23133

def body
  @body
end

#code ⇒ Object (readonly)

Returns the value of attribute code.



23133
23134
23135
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23133

def code
  @code
end

#details ⇒ Object (readonly)

Returns the value of attribute details.



23133
23134
23135
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23133

def details
  @details
end

#uri ⇒ Object (readonly)

Returns the value of attribute uri.



23133
23134
23135
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23133

def uri
  @uri
end

Instance Method Details

#body_json ⇒ Object



23153
23154
23155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23153

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

#message ⇒ Object



23145
23146
23147
23148
23149
23150
23151
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23145

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