lib/jellyfish.rb in jellyfish-0.5.1 vs lib/jellyfish.rb in jellyfish-0.5.2

- old
+ new

@@ -133,22 +133,25 @@ def call env ctrl = controller.new(self.class.routes, self) ctrl.call(env) rescue NotFound => e # forward if app - protect(ctrl, env){ app.call(env) } + begin + app.call(env) + rescue Exception => e + handle(ctrl, e, env['rack.errors']) + end else handle(ctrl, e) end rescue Exception => e handle(ctrl, e, env['rack.errors']) end - def protect ctrl, env - yield - rescue Exception => e - handle(ctrl, e, env['rack.errors']) + def log_error e, stderr + return unless stderr + stderr.puts("[#{self.class.name}] #{e.inspect} #{e.backtrace}") end private def handle ctrl, e, stderr=nil handler = self.class.handlers.find{ |klass, block| @@ -162,14 +165,9 @@ [e.status, e.headers, e.body] else # fallback and see if there's any InternalError handler log_error(e, stderr) handle(ctrl, InternalError.new) end - end - - def log_error e, stderr - return unless stderr - stderr.puts("[#{self.class.name}] #{e.inspect} #{e.backtrace}") end # ----------------------------------------------------------------- def self.included mod