Exception: BackchatClient::Error::GeneralError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/backchat_client/error/general_error.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ GeneralError

Returns a new instance of GeneralError.



6
7
8
# File 'lib/backchat_client/error/general_error.rb', line 6

def initialize(response = nil)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/backchat_client/error/general_error.rb', line 4

def response
  @response
end

Instance Method Details

#errorsObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/backchat_client/error/general_error.rb', line 14

def errors
  @errors||=(
    errors = nil
    if !response.nil? and response.respond_to?(:body)
      data = ActiveSupport::JSON.decode(response.body)
      data.has_key?("errors") and errors = data["errors"].flatten
    end
    errors
  )
    
end

#to_sObject



10
11
12
# File 'lib/backchat_client/error/general_error.rb', line 10

def to_s
  response
end