Sha256: 504a67d20f6ff888a2f3e0d6099ed39727823cb8fa30b606fdcbcd711b951e4a

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

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

    def call(env)
      @app.call(env)
    rescue
      excpt = $!
      request = env["action_controller.instance"].request
      params = request.filtered_parameters
      session = request.session.as_json
      page_url = request.url

      # Build the clean url (hide the port if it is obvious)
      url = "#{request.scheme}://#{request.host}"
      url << ":#{request.port}" unless [80, 443].include?(request.port)
      url << request.fullpath

      ::WatCatcher::SidekiqPoster.perform_async(
        "#{WatCatcher.configuration.host}/wats",
        {
            wat: {
                page_url: page_url,
                request_params: params,
                session: session,
                backtrace: excpt.backtrace.to_a,
                message: excpt.message,
                error_class: excpt.class.to_s
            }
        })
      raise
    end
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wat_catcher-0.1.0 lib/wat_catcher/middleware.rb