Exception: SwarmSDK::Hooks::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/swarm_sdk/hooks/error.rb

Overview

Error raised by callbacks to block execution

This error provides context about which hook failed and includes the execution context for debugging and error handling.

Examples:

Raise a hook error to block execution

raise SwarmSDK::Hooks::Error.new(
  "Validation failed: invalid syntax",
  hook_name: :validate_code,
  context: context
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, hook_name: nil, context: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String)

    Error message

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

    Name of the hook that failed

  • context (Context, nil) (defaults to: nil)

    Execution context when error occurred



22
23
24
25
26
# File 'lib/swarm_sdk/hooks/error.rb', line 22

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



17
18
19
# File 'lib/swarm_sdk/hooks/error.rb', line 17

def context
  @context
end

#hook_nameObject (readonly)

Returns the value of attribute hook_name.



17
18
19
# File 'lib/swarm_sdk/hooks/error.rb', line 17

def hook_name
  @hook_name
end