class Footrest::HttpError::ErrorBase
Attributes
body[R]
method[R]
response[R]
status[R]
Public Class Methods
new(response=nil)
click to toggle source
Calls superclass method
# File lib/footrest/http_error.rb, line 10 def initialize(response=nil) @response = response @status = @response[:status] @body = @response[:body] @method = @response[:method] super("HTTP ERROR: #{status} (#{status_message}) #{method} #{url}\n#{errors}\n#{headers}") end
Public Instance Methods
errors()
click to toggle source
# File lib/footrest/http_error.rb, line 36 def errors parsed_body = JSON::parse(@body) JSON::pretty_generate(parsed_body["errors"] || parsed_body) rescue @body end
headers()
click to toggle source
# File lib/footrest/http_error.rb, line 27 def headers JSON::pretty_generate( request: sanitized_request_headers, response: @response.response_headers ) rescue => e "[Unable to show headers: #{e}]" end
request_headers()
click to toggle source
# File lib/footrest/http_error.rb, line 52 def request_headers @response.request_headers end
sanitized_request_headers()
click to toggle source
# File lib/footrest/http_error.rb, line 47 def sanitized_request_headers return request_headers unless request_headers['Authorization'] request_headers.merge('Authorization' => truncated_authorization_value) end
status_message()
click to toggle source
# File lib/footrest/http_error.rb, line 43 def status_message HTTP_STATUS_CODES.fetch(status, 'UNKNOWN STATUS') end
url()
click to toggle source
# File lib/footrest/http_error.rb, line 23 def url @response.url.to_s end