Exception: Conductor::AuthorizationError

Inherits:
ApiError show all
Defined in:
lib/conductor/exceptions.rb

Overview

Authorization error (401/403 with special token handling)

Instance Attribute Summary collapse

Attributes inherited from ApiError

#body, #code, #headers, #reason, #status

Instance Method Summary collapse

Methods inherited from ApiError

#not_found?

Constructor Details

#initialize(message = nil, status: nil, body: nil, headers: nil) ⇒ AuthorizationError

Returns a new instance of AuthorizationError.



40
41
42
43
# File 'lib/conductor/exceptions.rb', line 40

def initialize(message = nil, status: nil, body: nil, headers: nil)
  @error_code = parse_error_code(body)
  super(message, status: status, body: body, headers: headers)
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



38
39
40
# File 'lib/conductor/exceptions.rb', line 38

def error_code
  @error_code
end

Instance Method Details

#invalid_token?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/conductor/exceptions.rb', line 49

def invalid_token?
  @error_code == 'INVALID_TOKEN'
end

#token_expired?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/conductor/exceptions.rb', line 45

def token_expired?
  @error_code == 'EXPIRED_TOKEN'
end