Exception: TokenError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/keycloak-api-rails/token_error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, reason, message, original_error) ⇒ TokenError

Returns a new instance of TokenError.



4
5
6
7
8
9
# File 'lib/keycloak-api-rails/token_error.rb', line 4

def initialize(token, reason, message, original_error)
  super(message)
  @token          = token
  @reason         = reason
  @original_error = original_error
end

Instance Attribute Details

#original_errorObject (readonly)

Returns the value of attribute original_error.



2
3
4
# File 'lib/keycloak-api-rails/token_error.rb', line 2

def original_error
  @original_error
end

#reasonObject (readonly)

Returns the value of attribute reason.



2
3
4
# File 'lib/keycloak-api-rails/token_error.rb', line 2

def reason
  @reason
end

#tokenObject (readonly)

Returns the value of attribute token.



2
3
4
# File 'lib/keycloak-api-rails/token_error.rb', line 2

def token
  @token
end

Class Method Details

.expired(token) ⇒ Object



23
24
25
# File 'lib/keycloak-api-rails/token_error.rb', line 23

def self.expired(token)
  TokenError.new(token, :expired, "JWT token is expired", nil)
end

.invalid_format(token, original_error) ⇒ Object



15
16
17
# File 'lib/keycloak-api-rails/token_error.rb', line 15

def self.invalid_format(token, original_error)
  TokenError.new(token, :invalid_format, "Wrong JWT Format", original_error)
end

.no_token(token) ⇒ Object



19
20
21
# File 'lib/keycloak-api-rails/token_error.rb', line 19

def self.no_token(token)
  TokenError.new(token, :no_token, "No JWT token provided", nil)
end

.unknown(token) ⇒ Object



27
28
29
# File 'lib/keycloak-api-rails/token_error.rb', line 27

def self.unknown(token)
  TokenError.new
end

.verification_failed(token, original_error) ⇒ Object



11
12
13
# File 'lib/keycloak-api-rails/token_error.rb', line 11

def self.verification_failed(token, original_error)
  TokenError.new(token, :verification_failed, "Failed to verify JWT token", original_error)
end