class FlightStats::API::ResponseError
The superclass to all errors that occur when making an API
request.
Attributes
request[R]
response[R]
Public Class Methods
new(request, response)
click to toggle source
# File lib/flightstats/api/errors.rb, line 11 def initialize request, response @request, @response = request, response end
Public Instance Methods
code()
click to toggle source
# File lib/flightstats/api/errors.rb, line 15 def code response.code.to_i if response end
message()
click to toggle source
# File lib/flightstats/api/errors.rb, line 30 def message json and json['error'] and json['error']['errorMessage'] end
to_s()
click to toggle source
Calls superclass method
FlightStats::Error#to_s
# File lib/flightstats/api/errors.rb, line 19 def to_s if description return CGI.unescapeHTML [description, details].compact.join(' ') end return super unless code "%d %s (%s %s)" % [ code, http_error, request.method, API.base_uri + request.path ] end
Private Instance Methods
http_error()
click to toggle source
# File lib/flightstats/api/errors.rb, line 40 def http_error Helper.demodulize self.class.name.gsub(/([a-z])([A-Z])/, '\1 \2') end
json()
click to toggle source
# File lib/flightstats/api/errors.rb, line 44 def json return @json if defined? @json @json = (JSON.parse(response.body) if response && !response.body.empty?) end