Exception: CyberSource::Authentication::Util::JWT::JWTException
- Inherits:
-
StandardError
- Object
- StandardError
- CyberSource::Authentication::Util::JWT::JWTException
- Defined in:
- lib/AuthenticationSDK/util/JWT/JWTExceptions.rb
Overview
Base JWT Exception Class
Provides enhanced exception handling for JWT-related operations with error chaining and detailed stack trace information.
Direct Known Subclasses
InvalidJwkException, InvalidJwtException, JwtSignatureValidationException
Instance Method Summary collapse
-
#cause_chain_messages ⇒ Array<String>
Error messages from all exceptions in the chain.
-
#exception_chain ⇒ Array<Exception>
Array of exceptions in the chain.
-
#full_message(highlight: false, order: :top) ⇒ String
Detailed error message with all causes.
-
#has_cause? ⇒ Boolean
True if a cause exception exists.
-
#initialize(message = '', cause = nil) ⇒ JWTException
constructor
A new instance of JWTException.
-
#root_cause ⇒ Exception
The root cause of the exception chain.
-
#to_s ⇒ String
Exception string with cause information.
Constructor Details
#initialize(message = '', cause = nil) ⇒ JWTException
Returns a new instance of JWTException.
14 15 16 17 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 14 def initialize( = '', cause = nil) super() set_backtrace(cause.backtrace) if cause&.backtrace end |
Instance Method Details
#cause_chain_messages ⇒ Array<String>
Returns Error messages from all exceptions in the chain.
50 51 52 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 50 def exception_chain.map(&:message) end |
#exception_chain ⇒ Array<Exception>
Returns Array of exceptions in the chain.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 32 def exception_chain chain = [self] current = cause while current chain << current current = current.cause end chain end |
#full_message(highlight: false, order: :top) ⇒ String
Returns Detailed error message with all causes.
57 58 59 60 61 62 63 64 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 57 def (highlight: false, order: :top, **) = exception_chain.each_with_index.map do |exception, index| prefix = index.zero? ? '' : 'Caused by: ' "#{prefix}#{exception.class}: #{exception.}" end order == :bottom ? .reverse.join("\n") : .join("\n") end |
#has_cause? ⇒ Boolean
Returns True if a cause exception exists.
20 21 22 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 20 def has_cause? !cause.nil? end |
#root_cause ⇒ Exception
Returns The root cause of the exception chain.
45 46 47 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 45 def root_cause exception_chain.last end |
#to_s ⇒ String
Returns Exception string with cause information.
25 26 27 28 29 |
# File 'lib/AuthenticationSDK/util/JWT/JWTExceptions.rb', line 25 def to_s return super unless has_cause? "#{super}\nCaused by: #{cause}" end |