Exception: Improvmx::CommunicationError
- Defined in:
- lib/improvmx/exceptions/exceptions.rb
Overview
Public: Class for managing communications (eg http) response errors
Direct Known Subclasses
AuthenticationError, BadRequestError, NotFoundError, RateLimitError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(message = nil, response = nil) ⇒ CommunicationError
constructor
Public: initialization of new error given a message and/or object.
Constructor Details
#initialize(message = nil, response = nil) ⇒ CommunicationError
Public: initialization of new error given a message and/or object
message - a String detailing the error response - a RestClient::Response object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/improvmx/exceptions/exceptions.rb', line 24 def initialize( = nil, response = nil) @response = response @code = response.code json = JSON.parse(response.body) = json['error'] || json['errors'] ||= '' = "#{} #{}" super(, response) rescue NoMethodError, JSON::ParserError super(, response) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
17 18 19 |
# File 'lib/improvmx/exceptions/exceptions.rb', line 17 def code @code end |