Exception: Hooksmith::InvalidPayloadError

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

Overview

Raised when the payload is invalid or malformed.

This error can be raised during payload validation when the webhook data doesn't match expected schema or format.

Examples:

raise Hooksmith::InvalidPayloadError.new(
  'Missing required field: id',
  provider: 'stripe',
  event: 'charge.succeeded'
)

Instance Attribute Summary collapse

Attributes inherited from Error

#event, #provider

Instance Method Summary collapse

Constructor Details

#initialize(message = 'Invalid webhook payload', provider: nil, event: nil, validation_errors: []) ⇒ InvalidPayloadError

Initializes a new InvalidPayloadError.

Parameters:

  • message (String) (defaults to: 'Invalid webhook payload')

    the error message

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

    the provider name

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

    the event name

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

    list of validation errors



196
197
198
199
# File 'lib/hooksmith/errors.rb', line 196

def initialize(message = 'Invalid webhook payload', provider: nil, event: nil, validation_errors: [])
  @validation_errors = validation_errors
  super(message, provider:, event:)
end

Instance Attribute Details

#validation_errorsArray<String> (readonly)

Returns list of validation errors.

Returns:

  • (Array<String>)

    list of validation errors



188
189
190
# File 'lib/hooksmith/errors.rb', line 188

def validation_errors
  @validation_errors
end