class ConvertApi::ClientError
Attributes
response[R]
Public Class Methods
new(response)
click to toggle source
# File lib/convert_api/errors.rb, line 12 def initialize(response) @response = response end
Public Instance Methods
code()
click to toggle source
# File lib/convert_api/errors.rb, line 26 def code response_json['Code'] end
error_message()
click to toggle source
# File lib/convert_api/errors.rb, line 22 def error_message response_json['Message'] end
http_status()
click to toggle source
# File lib/convert_api/errors.rb, line 34 def http_status response[:status] end
invalid_parameters()
click to toggle source
# File lib/convert_api/errors.rb, line 30 def invalid_parameters response_json['InvalidParameters'] end
response_json()
click to toggle source
# File lib/convert_api/errors.rb, line 38 def response_json @response_json ||= begin JSON.parse(response[:body]) rescue JSON::ParserError {} end end
to_s()
click to toggle source
# File lib/convert_api/errors.rb, line 16 def to_s return "the server responded with status #{http_status}" unless json? "#{error_message} Code: #{code}. #{invalid_parameters}".strip end
Private Instance Methods
json?()
click to toggle source
# File lib/convert_api/errors.rb, line 48 def json? response[:headers]['content-type'] =~ /json/ end