Exception: Chatrix::AuthenticationError

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

Overview

Raised when there is an issue with authentication.

This can either be because authentication failed outright or because more information is required by the server to successfully authenticate.

If authentication failed then the data attribute will be an empty hash.

If more information is required the data hash will contain information about what additional information is needed to authenticate.

Instance Attribute Summary collapse

Attributes inherited from ApiError

#api_message, #code, #error

Instance Method Summary collapse

Constructor Details

#initialize(error = {}) ⇒ AuthenticationError

Initializes a new AuthenticationError instance.

Parameters:

  • error (Hash) (defaults to: {})

    The error response from the server.



116
117
118
119
120
121
122
123
# File 'lib/chatrix/errors.rb', line 116

def initialize(error = {})
  super

  # Set data to be the error response hash WITHOUT the error code and
  # error values. This will leave it with only the data relevant for
  # handling authentication.
  @data = error.select { |key| !%w(errcode error).include? key }
end

Instance Attribute Details

#dataHash (readonly)

Returns a hash with information about the additional information required by the server for authentication, if any. If the authentication request failed, this will be an empty hash or nil.

Returns:

  • (Hash)

    a hash with information about the additional information required by the server for authentication, if any. If the authentication request failed, this will be an empty hash or nil.



112
113
114
# File 'lib/chatrix/errors.rb', line 112

def data
  @data
end