Permalink
Browse files

dump always the message and in case there is no dumps create default …

…error page and dump to console
  • Loading branch information...
1 parent 454d576 commit 7792f8c6f8900f72d5fea396f8180c2aec877e43 @mkristian committed Sep 25, 2013
Showing with 11 additions and 4 deletions.
  1. +11 −4 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

0 comments on commit 7792f8c

Please sign in to comment.