replace "rescue => e" with "rescue Object => e"
[unicorn.git] / lib / unicorn / app / old_rails.rb
blobe674d7802a6eedb2cbeb8cc9f71e006385f2d541
1 # -*- encoding: binary -*-
3 # This code is based on the original Rails handler in Mongrel
4 # Copyright (c) 2005 Zed A. Shaw
5 # Copyright (c) 2009 Eric Wong
6 # You can redistribute it and/or modify it under the same terms as Ruby.
7 # Additional work donated by contributors.  See CONTRIBUTORS for more info.
8 require 'unicorn/cgi_wrapper'
9 require 'dispatcher'
11 module Unicorn; module App; end; end
13 # Implements a handler that can run Rails.
14 class Unicorn::App::OldRails
16   autoload :Static, "unicorn/app/old_rails/static"
18   def call(env)
19     cgi = Unicorn::CGIWrapper.new(env)
20     begin
21       Dispatcher.dispatch(cgi,
22           ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
23           cgi.body)
24     rescue => e
25       err = env['rack.errors']
26       err.write("#{e} #{e.message}\n")
27       e.backtrace.each { |line| err.write("#{line}\n") }
28     end
29     cgi.out  # finalize the response
30     cgi.rack_response
31   end
33 end