Sha256: 96afd59bcd780032bea6e13cdac25c08fff5a49571a8ffc7002c7f65651ff7d5

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Web
    module Middleware
      #
      # Error notification adapter for Rack app
      #
      class ErrorNotificationAdapter
        include Mihari::Mixins::UnwrapError

        attr_reader :app

        def initialize(app)
          @app = app
        end

        def with_error_notification
          yield
        rescue StandardError => e
          unwrapped = unwrap_error(e)

          Mihari.logger.error unwrapped
          Sentry.capture_exception(unwrapped) if Sentry.initialized?

          raise unwrapped
        end

        def call(env)
          with_error_notification { app.call(env) }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/web/middleware/error_notification_adapter.rb
mihari-6.2.0 lib/mihari/web/middleware/error_notification_adapter.rb
mihari-6.1.0 lib/mihari/web/middleware/error_notification_adapter.rb
mihari-6.0.0 lib/mihari/web/middleware/error_notification_adapter.rb