Exception: Chatrix::ApiError

Inherits:
ChatrixError show all
Defined in:
lib/chatrix/errors.rb

Overview

Errors that stem from an API call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error = {}) ⇒ ApiError

Initializes a new RequestError instance.

Parameters:

  • error (Hash{String=>String}) (defaults to: {})

    The error response object.



24
25
26
27
28
# File 'lib/chatrix/errors.rb', line 24

def initialize(error = {})
  @error = error
  @code = error['errcode'] || 'E_UNKNOWN'
  @api_message = error['error'] || 'Unknown error'
end

Instance Attribute Details

#api_messageString (readonly)

Returns the error message returned from the server. 'Unknown error' if the server did not give any message.

Returns:

  • (String)

    the error message returned from the server. 'Unknown error' if the server did not give any message.



20
21
22
# File 'lib/chatrix/errors.rb', line 20

def api_message
  @api_message
end

#codeString (readonly)

Returns the type of error. 'E_UNKNOWN' if the server did not give an error code.

Returns:

  • (String)

    the type of error. 'E_UNKNOWN' if the server did not give an error code.



16
17
18
# File 'lib/chatrix/errors.rb', line 16

def code
  @code
end

#errorHash (readonly)

Returns the raw error response object.

Returns:

  • (Hash)

    the raw error response object.



12
13
14
# File 'lib/chatrix/errors.rb', line 12

def error
  @error
end