Sha256: c6092e4c179c9e81cf2cb364f09bfbda6d2d1f6d5d92d97c21f2badee123384f

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Whoopsie
  class Railtie < Rails::Railtie
    Config = Struct.new(:enable, :recipients, :sender, :email_prefix)
    config.whoopsie = Config.new

    initializer 'whoopsie.configure_middleware' do
      Rails.application.middleware.insert_before(
        ActiveRecord::ConnectionAdapters::ConnectionManagement,
        ExceptionNotification::Rack
      )

      # Include the helper
      ActionView::Base.send(:include, WhoopsieHelper)

      ExceptionNotification.configure do |config|
        # Ignore additional exception types.

        # ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and
        # ActionController::RoutingError are already added.
        # config.ignored_exceptions += %w{ActionView::TemplateError CustomError}

        # Adds a condition to decide when an exception must be ignored or not.
        # The ignore_if method can be invoked multiple times to add extra conditions.
        # config.ignore_if do |exception, options|
        #   ! Rails.application.config.whoopsie.enable
        # end

        if Rails.application.config.whoopsie.enable
          config.add_notifier(
            :email,
            email_prefix:         Rails.application.config.whoopsie.email_prefix || '[ERROR] ',
            sender_address:       Rails.application.config.whoopsie.sender,
            exception_recipients: Rails.application.config.whoopsie.recipients
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whoopsie-0.0.2 lib/whoopsie/railtie.rb