Exception: Rentlinx::BadRequest

Inherits:
HTTPError show all
Defined in:
lib/rentlinx/errors.rb

Overview

Thrown when error code 400 (bad request) is received

Instance Attribute Summary

Attributes inherited from HTTPError

#response

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ BadRequest

Returns a new instance of BadRequest.



57
58
59
60
61
62
63
64
65
# File 'lib/rentlinx/errors.rb', line 57

def initialize(response)
  default_message = 'The request sent to the server was invalid.'
  begin
    message = JSON.parse(response.body)['details'] || default_message
  rescue JSON::ParserError
    message = default_message
  end
  super(response, message)
end