Sha256: 387bb19b3a9a26a94d0d1b24e4962bb7f11ac91a296e2876a979493c30d7d472

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

# code:
# * George Moschovitis  <gm@navel.gr>
#
# (c) 2004 Navel, all rights reserved.
# $Id: dispatcher.rb 167 2004-11-23 14:03:10Z gmosx $

require 'nitro/server/render'

module N

# = Dispatcher
#
module Dispatcher 
	include N::Render
	
	def process(request, response)
		begin
			$og.get_connection if $og
			
			session = create_session(request, response)
			render(request.request_uri.path, request, response, session)
			response.body = @out 
		rescue Exception, StandardError => e
			$log.error "error while handling the request #{request.request_uri}"
			$log.error pp_exception(e)

			if $error_page_url
				# gmosx: SOS: TEST ME!
				# internal redirect to error page. 
				request.request_uri.path = $error_page_url
				retry
			else
				# no custom error page defined. Presen a simple yet 
				# useful error screen.
				response.header['Content-Type'] = 'text/html'
				body = %{
					<h1>ERROR</h1>
					<p>Click <a href="#{request.referer}">here</a> to return 
					to the previous page.</p>
				}
=begin				
				if request.error_log
					body << %{
						<h3>Request error log</h3>
						<pre>#{request.error_log.join("\n")}</pre>
					}
				end
=end
				body << %{
					<h3>Exception</h3>
					<pre>#{pp_exception(e)}</pre>
				}
				response.body = body
			end			
		ensure
			$og.put_connection if $og
		end
	end	

end

end # module

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.5.0 lib/nitro/server/dispatcher.rb
nitro-0.6.0 lib/nitro/server/dispatcher.rb