Sha256: 1470e6bf6d716ffd19d0b81628c4a1c9a31972d3da952fe15004a3678a35bb6d

Contents?: true

Size: 728 Bytes

Versions: 13

Compression:

Stored size: 728 Bytes

Contents

require "logtail/config"
require "logtail/events/error"
require "logtail-rack/middleware"

module Logtail
  module Integrations
    module Rack
      # A Rack middleware that is reponsible for capturing exception and error events
      class ErrorEvent < Middleware
        def call(env)
          begin
            status, headers, body = @app.call(env)
          rescue Exception => exception
            Config.instance.logger.fatal do
              Events::Error.new(
                name: exception.class.name,
                error_message: exception.message,
                backtrace: exception.backtrace
              )
            end

            raise exception
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
logtail-rack-0.2.5 lib/logtail-rack/error_event.rb
logtail-rack-0.2.4 lib/logtail-rack/error_event.rb
logtail-rack-0.2.3 lib/logtail-rack/error_event.rb
logtail-rack-0.2.2 lib/logtail-rack/error_event.rb
logtail-rack-0.2.1 lib/logtail-rack/error_event.rb
logtail-rack-0.2.0 lib/logtail-rack/error_event.rb
logtail-rack-0.1.6 lib/logtail-rack/error_event.rb
logtail-rack-0.1.5 lib/logtail-rack/error_event.rb
logtail-rack-0.1.4 lib/logtail-rack/error_event.rb
logtail-rack-0.1.3 lib/logtail-rack/error_event.rb
logtail-rack-0.1.2 lib/logtail-rack/error_event.rb
logtail-rack-0.1.1 lib/logtail-rack/error_event.rb
logtail-rack-0.1.0 lib/logtail-rack/error_event.rb