Exception: Verikloak::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/verikloak/errors.rb

Overview

Base error class for all Verikloak-related exceptions.

All errors raised by this library inherit from this class so they can be rescued in a consistent way. Each error may carry a short, programmatic ‘code` (e.g., “invalid_token”, “jwks_fetch_failed”) that middleware and callers can use to map to HTTP statuses or telemetry.

Examples:

Raising with a code

raise Verikloak::Error.new("Something went wrong", code: "internal_error")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String, nil) (defaults to: nil)

    Human-readable error message.

  • code (String, Symbol, nil) (defaults to: nil)

    Optional short error code for programmatic handling.



21
22
23
24
# File 'lib/verikloak/errors.rb', line 21

def initialize(message = nil, code: nil)
  super(message)
  @code = code
end

Instance Attribute Details

#codeString, ... (readonly)

A short error code identifier suitable for programmatic handling.

Returns:

  • (String, Symbol, nil)

    the current value of code



16
17
18
# File 'lib/verikloak/errors.rb', line 16

def code
  @code
end