class BlazingDocs::BlazingError
Attributes
response[R]
Public Class Methods
new(response)
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 5 def initialize(response) 6 @response = response 7 end
Public Instance Methods
error_message()
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 15 def error_message 16 response_json['message'] 17 end
errors()
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 19 def errors 20 response_json['errors'] 21 end
http_status()
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 23 def http_status 24 response[:status] 25 end
response_json()
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 27 def response_json 28 @response_json ||= begin 29 JSON.parse(response[:body]) 30 rescue JSON::ParserError 31 {} 32 end 33 end
to_s()
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 9 def to_s 10 return "the server responded with status #{http_status}" unless json? 11 12 "Status: #{http_status}. Error message: #{error_message}. Errors: #{errors}".strip 13 end
Private Instance Methods
json?()
click to toggle source
# File lib/blazingdocs/errors/blazing_error.rb 37 def json? 38 response[:headers]['content-type'] =~ /json/ 39 end