class Sinatra::ShowExceptions

information helpful to attackers.
Be careful when you use this on public-facing sites as it could reveal
context, the whole Rack environment and the request data.
wraps. It shows a useful backtrace with the sourcefile and clickable
Sinatra::ShowExceptions catches all exceptions raised from the app it

def bad_request?(e)

def bad_request?(e)
  Sinatra::BadRequest === e
end

def call(env)

def call(env)
  @app.call(env)
rescue Exception => e
  errors, env["rack.errors"] = env["rack.errors"], @@eats_errors
  if prefers_plain_text?(env)
    content_type = "text/plain"
    body = dump_exception(e)
  else
    content_type = "text/html"
    body = pretty(env, e)
  end
  env["rack.errors"] = errors
  [
    500,
    {
      "Content-Type" => content_type,
      "Content-Length" => body.bytesize.to_s
    },
    [body]
  ]
end

def frame_class(frame)

def frame_class(frame)
  if frame.filename =~ %r{lib/sinatra.*\.rb}
    "framework"
  elsif (defined?(Gem) && frame.filename.include?(Gem.dir)) ||
        frame.filename =~ %r{/bin/(\w+)\z}
    "system"
  else
    "app"
  end
end

def initialize(app)

def initialize(app)
  @app = app
end

def prefers_plain_text?(env)

def prefers_plain_text?(env)
  !(Request.new(env).preferred_type("text/plain","text/html") == "text/html") &&
  [/curl/].index { |item| item =~ env["HTTP_USER_AGENT"] }
end

def template

def template
  TEMPLATE
end