Skip to content

Commit

Permalink
dump always the message and in case there is no dumps create default …
Browse files Browse the repository at this point in the history
…error page and dump to console
  • Loading branch information
mkristian committed Sep 25, 2013
1 parent 454d576 commit 7792f8c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/ixtlan/errors/rack.rb
Expand Up @@ -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 }
Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 7792f8c

Please sign in to comment.