Class: Rack::ErrorPage

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_errorpage.rb

Overview

Catches all exceptions, forgets about them, and displays the given html file wth a status of 500

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, filename) ⇒ ErrorPage

Returns a new instance of ErrorPage.



11
12
13
14
# File 'lib/rack_errorpage.rb', line 11

def initialize(app,filename)
  @app = app
  @filename = filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



9
10
11
# File 'lib/rack_errorpage.rb', line 9

def filename
  @filename
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/rack_errorpage.rb', line 16

def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue => boom
      render_page
    end
  render_page if env['rack.exception']
  [status, headers, body]
end