Sha256: f0f2b819d86c44977446ac8b152f4d28b391ba5e4529b0b94132eb0b43d449dc

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

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

    def call(env)
      better_errors_fix env
      @app.call env
    rescue StandardError => ex
      if [ex.class, ex.cause.class].map(&:to_s).include? "DebugExtras::DebugData"
        debug_page = DebugPage.new(ex, env["PATH_INFO"])
        [200, { "Content-Type" => "text/html; charset=utf-8" }, [debug_page.render]]
      else
        @app.call env
      end
    end

    private

    # based on https://github.com/charliesome/better_errors/issues/341
    def better_errors_fix(env)
      env["puma.config"].options.user_options.delete(:app) if env.has_key?("puma.config")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
debug-extras-0.3.0 lib/debug_extras/middleware.rb