Sha256: c8759b40ed9be2ae7b47f658efc41a6680e31a37a17a732a13a13c661de0731b

Contents?: true

Size: 590 Bytes

Versions: 3

Compression:

Stored size: 590 Bytes

Contents

module ExceptionAlarm
  class Middleware
    def initialize(app)
      @app = app
    end

    def call(env)
      @app.call(env)
    rescue Exception => exception
      if Rails.application.config.exception_alarm.enable && !ignore_exceptions.include?(exception.class.to_s) && ::ExceptionAlarm::Mailer.recipients.present?
        ::ExceptionAlarm::Mailer.alarm(env, exception).deliver
      end

      raise exception
    end

    protected
    def ignore_exceptions
      %w[ActiveRecord::RecordNotFound AbstractController::ActionNotFound ActionController::RoutingError]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exception-alarm-1.0.2 lib/exception_alarm/middleware.rb
exception-alarm-1.0.1 lib/exception_alarm/middleware.rb
exception-alarm-1.0.0 lib/exception_alarm/middleware.rb