Exception: Genius::Errors::TokenError

Inherits:
GeniusExceptionSuperClass show all
Defined in:
lib/genius/api/errors.rb

Overview

A TokenError object provides handling error during token validation. It throws error when token is invalid - expired, revoked or something else. To generate new token you should go to genius.com/signup_or_login and login, then you need to create new client via the link below: genius.com/api-clients and generate new access token. Fields to create new api client can be filled in as you like - there is no restrictions and standards.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg: 'Invalid token. The access token provided is expired, revoked, malformed or invalid for ' \ 'other reasons.', exception_type: 'token_error', method_name: nil) ⇒ void

Initializes a token validation error with optional method name hint.

Parameters:

  • msg (String) (defaults to: 'Invalid token. The access token provided is expired, revoked, malformed or invalid for ' \ 'other reasons.')

    Error message.

  • exception_type (String) (defaults to: 'token_error')

    Error type identifier.

  • method_name (String?) (defaults to: nil)

    Optional method name for user hint.



68
69
70
71
72
73
74
75
76
77
# File 'lib/genius/api/errors.rb', line 68

def initialize(msg: 'Invalid token. The access token provided is expired, revoked, malformed or invalid for ' \
                    'other reasons.', exception_type: 'token_error', method_name: nil)
  @msg = if method_name.nil?
           msg
         else
           "#{msg} or type #{method_name}(token: \"YOUR_TOKEN\")"
         end
  @exception_type = exception_type
  super(msg)
end

Instance Attribute Details

#exception_typeObject (readonly)

Returns the value of attribute exception_type.



60
61
62
# File 'lib/genius/api/errors.rb', line 60

def exception_type
  @exception_type
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



60
61
62
# File 'lib/genius/api/errors.rb', line 60

def method_name
  @method_name
end

#msgObject (readonly)

Returns the value of attribute msg.



60
61
62
# File 'lib/genius/api/errors.rb', line 60

def msg
  @msg
end