Exception: Hooksmith::VerificationError

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

Overview

Raised when webhook request verification fails.

This error is raised by verifiers when the incoming request does not pass authentication checks.

Examples:

Raising a verification error

raise Hooksmith::VerificationError, 'Invalid signature'

Raising with additional context

raise Hooksmith::VerificationError.new('Signature mismatch', provider: 'stripe', reason: 'invalid_hmac')

Instance Attribute Summary collapse

Attributes inherited from Error

#event, #provider

Instance Method Summary collapse

Constructor Details

#initialize(message = 'Webhook verification failed', provider: nil, event: nil, reason: nil) ⇒ VerificationError

Initializes a new VerificationError.

Parameters:

  • message (String) (defaults to: 'Webhook verification failed')

    the error message

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

    the provider name

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

    the event name

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

    additional reason for failure



55
56
57
58
# File 'lib/hooksmith/errors.rb', line 55

def initialize(message = 'Webhook verification failed', provider: nil, event: nil, reason: nil)
  @reason = reason
  super(message, provider:, event:)
end

Instance Attribute Details

#reasonString? (readonly)

Returns the reason for verification failure.

Returns:

  • (String, nil)

    the reason for verification failure



47
48
49
# File 'lib/hooksmith/errors.rb', line 47

def reason
  @reason
end