Exception: Hooksmith::MultipleProcessorsError

Inherits:
Error
  • Object
show all
Defined in:
lib/hooksmith/errors.rb

Overview

Raised when multiple processors can handle the same event.

This error is raised when more than one processor's can_handle? method returns true for the same webhook event. Hooksmith enforces exactly-one processor semantics.

This error intentionally does not include the full payload in the message to prevent PII exposure in logs and error tracking systems.

Examples:

raise Hooksmith::MultipleProcessorsError.new('stripe', 'charge.succeeded', payload)

Instance Attribute Summary collapse

Attributes inherited from Error

#event, #provider

Instance Method Summary collapse

Constructor Details

#initialize(provider, event, payload, processor_names: []) ⇒ MultipleProcessorsError

Initializes the error with details about the provider and event.

Parameters:

  • provider (String, Symbol)

    the provider name

  • event (String, Symbol)

    the event name

  • payload (Hash)

    the webhook payload (not included in message to prevent PII exposure)

  • processor_names (Array<String>) (defaults to: [])

    the names of the matching processor classes



107
108
109
110
111
112
113
114
115
# File 'lib/hooksmith/errors.rb', line 107

def initialize(provider, event, payload, processor_names: [])
  @payload_size = payload.to_s.bytesize
  @processor_names = processor_names
  super(
    "Multiple processors found for #{provider} event #{event} (payload_size=#{@payload_size} bytes)",
    provider:,
    event:
  )
end

Instance Attribute Details

#payload_sizeInteger (readonly)

Returns the number of bytes in the payload (for debugging).

Returns:

  • (Integer)

    the number of bytes in the payload (for debugging)



97
98
99
# File 'lib/hooksmith/errors.rb', line 97

def payload_size
  @payload_size
end

#processor_namesArray<String> (readonly)

Returns the names of the matching processor classes.

Returns:

  • (Array<String>)

    the names of the matching processor classes



99
100
101
# File 'lib/hooksmith/errors.rb', line 99

def processor_names
  @processor_names
end