From 7792f8c6f8900f72d5fea396f8180c2aec877e43 Mon Sep 17 00:00:00 2001 From: Christian Meier Date: Wed, 25 Sep 2013 11:13:35 +0100 Subject: [PATCH] dump always the message and in case there is no dumps create default error page and dump to console --- lib/ixtlan/errors/rack.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/ixtlan/errors/rack.rb b/lib/ixtlan/errors/rack.rb index e7044a2..0990ac6 100644 --- a/lib/ixtlan/errors/rack.rb +++ b/lib/ixtlan/errors/rack.rb @@ -48,7 +48,6 @@ class Rack def initialize(app, dumper, map = {} ) @app = app @dumper = dumper - @dump_to_console = dumper.keep_dumps == 0 @map = {} DEFAULT_MAP.each do |status, list| list.each { |exp| @map[ exp ] = status } @@ -58,6 +57,10 @@ def initialize(app, dumper, map = {} ) end end + def dump_to_console + @dumper.keep_dumps == 0 + end + def call(env) begin @app.call(env) @@ -67,13 +70,17 @@ def call(env) req = ::Rack::Request.new env @dumper.dump( e, env, {}, req.session, req.params ) end - if @dump_to_console - warn "[Ixtlan::Errors] #{e.class}: #{e.message}" + warn "[Ixtlan::Errors] #{e.class}: #{e.message}" + if dump_to_console + # dump to console and raise exception to let rack create + # an error page warn "\t" + e.backtrace.join( "\n\t" ) if e.backtrace && status >= 500 - end + raise e + else [ status, {'Content-Type' => 'text/plain'}, [ ::Rack::Utils::HTTP_STATUS_CODES[ status ] ] ] + end end end