Sha256: bae1adc68d0c56fb105f27ef04ce997655214cb3cf8475c8c01bf66b595f9bb3

Contents?: true

Size: 647 Bytes

Versions: 4

Compression:

Stored size: 647 Bytes

Contents

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

    def call(env)
      reset_stack
      @app.call env
    rescue StandardError => ex
      process_exception(ex, env)
    end

    private

    def reset_stack
      $debug_extras_add_styles = false
      $debug_extras_messages = []
    end

    def process_exception(ex, env)
      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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
debug-extras-0.4.3 lib/debug_extras/middleware/debug.rb
debug-extras-0.4.2 lib/debug_extras/middleware/debug.rb
debug-extras-0.4.1 lib/debug_extras/middleware/debug.rb
debug-extras-0.4.0 lib/debug_extras/middleware/debug.rb