Exception: Gaskit::OperationExit

Inherits:
Error
  • Object
show all
Defined in:
lib/gaskit/operation_exit.rb

Overview

OperationExit is a custom exception representing an early exit from an operation.

It communicates intent-based flow interruption (e.g., authorization failure, validation issue) and includes a symbolic ‘key`, optional `message`, and optional `code`.

Examples:

Raising an OperationExit with just a key

exit(:unauthorized)

With a custom message and code

exit(:unauthorized, "Access denied", code: "AUTH-001")

Handling OperationExit in a flow

begin
  MyFlow.call!
rescue Gaskit::OperationExit => e
  puts "Exited: #{e.key} - #{e.message} (#{e.code})"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, message = nil, code: nil) ⇒ OperationExit

Initializes an OperationExit.

Parameters:

  • key (Symbol, String)

    The symbolic exit key

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

    A human-readable message (defaults to key if not provided)

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

    A structured error code for analytics or debugging



33
34
35
36
37
# File 'lib/gaskit/operation_exit.rb', line 33

def initialize(key, message = nil, code: nil)
  super(message || "early exit")
  @key = key
  @code = code
end

Instance Attribute Details

#codeString? (readonly)

Returns Optional structured code (e.g., “AUTH-001”).

Returns:

  • (String, nil)

    Optional structured code (e.g., “AUTH-001”)



26
27
28
# File 'lib/gaskit/operation_exit.rb', line 26

def code
  @code
end

#keySymbol, String (readonly)

Returns The symbolic or textual reason for the early exit.

Returns:

  • (Symbol, String)

    The symbolic or textual reason for the early exit



23
24
25
# File 'lib/gaskit/operation_exit.rb', line 23

def key
  @key
end

Instance Method Details

#inspectObject



39
40
41
# File 'lib/gaskit/operation_exit.rb', line 39

def inspect
  "#<#{self.class} key=#{key.inspect} message=#{message.inspect} code=#{code.inspect}>"
end