Exception: Chatkit::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/chatkit/response_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform_error) ⇒ ResponseError

Returns a new instance of ResponseError.



7
8
9
10
11
12
13
# File 'lib/chatkit/response_error.rb', line 7

def initialize(platform_error)
  @status = platform_error.status
  @headers = platform_error.headers
  @error = platform_error.error
  @error_description = platform_error.error_description
  @error_uri = platform_error.error_uri
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/chatkit/response_error.rb', line 5

def error
  @error
end

#error_descriptionObject (readonly)

Returns the value of attribute error_description.



5
6
7
# File 'lib/chatkit/response_error.rb', line 5

def error_description
  @error_description
end

#error_uriObject (readonly)

Returns the value of attribute error_uri.



5
6
7
# File 'lib/chatkit/response_error.rb', line 5

def error_uri
  @error_uri
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/chatkit/response_error.rb', line 5

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/chatkit/response_error.rb', line 5

def status
  @status
end

Instance Method Details

#as_json(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/chatkit/response_error.rb', line 21

def as_json(options = {})
  json = {
    status: @status,
    headers: @headers,
    error: @error,
    error_description: @error_description,
  }
  json[:error_uri] = @error_uri unless @error_uri.nil?
  json
end

#to_json(*options) ⇒ Object



32
33
34
# File 'lib/chatkit/response_error.rb', line 32

def to_json(*options)
  as_json(*options).to_json(*options)
end

#to_sObject



15
16
17
18
19
# File 'lib/chatkit/response_error.rb', line 15

def to_s
  output = "Chatkit::ResponseError - status: #{@status} description: #{@error_description}."
  output += " Find out more at #{@error_uri}" if @error_uri
  output
end