Class: Sinatra::ShowExceptions

### Home Classes Methods

### In Files

- lib/sinatra/show_exceptions.rb

### Parent

Rack::ShowExceptions

### Methods

- ::new
- #call

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Sinatra
- Sinatra::Application
- Sinatra::CommonLogger
- Sinatra::ExtendedRack
- Sinatra::Helpers
- Sinatra::Helpers::Stream
- Sinatra::Helpers::Stream::Application
- Sinatra::Helpers::Stream::Base
- Sinatra::Helpers::Stream::Templates
- Sinatra::Helpers::Stream::Templates::ContentTyped
- Sinatra::Helpers::Stream::Wrapper
- Sinatra::Request
- Sinatra::Request::AcceptEntry
- Sinatra::Response
- Sinatra::ShowExceptions
- Rack
- Rack::Builder

No matching classes.

# Sinatra::ShowExceptions

Sinatra::ShowExceptions catches all exceptions raised from the app it wraps. It shows a useful backtrace with the sourcefile and clickable context, the whole Rack environment and the request data.

Be careful when you use this on public-facing sites as it could reveal information helpful to attackers.

### Public Class Methods

new(app) click to toggle source

    # File lib/sinatra/show_exceptions.rb, line 15
    def initialize(app)
      @app      = app
      @template = ERB.new(TEMPLATE)
    end

### Public Instance Methods

call(env) click to toggle source

    # File lib/sinatra/show_exceptions.rb, line 20
    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" => Rack::Utils.bytesize(body.join).to_s},
       body]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.