Exception: Hooksmith::Error

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

Overview

Base error class for all Hooksmith errors.

All Hooksmith errors inherit from this class, allowing you to rescue all Hooksmith-related errors with a single rescue clause.

Examples:

Rescuing all Hooksmith errors

begin
  Hooksmith::Dispatcher.new(...).run!
rescue Hooksmith::Error => e
  logger.error("Hooksmith error: #{e.message}")
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, provider: nil, event: nil) ⇒ Error

Initializes a new Error.

Parameters:

  • message (String) (defaults to: nil)

    the error message

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

    the provider name

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

    the event name



27
28
29
30
31
# File 'lib/hooksmith/errors.rb', line 27

def initialize(message = nil, provider: nil, event: nil)
  @provider = provider&.to_s
  @event = event&.to_s
  super(message)
end

Instance Attribute Details

#eventString? (readonly)

Returns the event name.

Returns:

  • (String, nil)

    the event name



20
21
22
# File 'lib/hooksmith/errors.rb', line 20

def event
  @event
end

#providerString? (readonly)

Returns the provider name.

Returns:

  • (String, nil)

    the provider name



18
19
20
# File 'lib/hooksmith/errors.rb', line 18

def provider
  @provider
end