Permalink
Browse files

FailMiddleware from old failurous-rails, using the failurous-ruby's F…

…ailurous.notify
  • Loading branch information...
1 parent 239a69e commit 5de58aa301aa4882b79c3cc9213ea365d1ca588d @mnylen committed Nov 3, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 lib/failurous/rails/fail_middleware.rb
@@ -0,0 +1,24 @@
+module Failurous::Rails
+ class FailMiddleware
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ @app.call(env)
+ rescue Exception => exception
+ unless Failurous.notifier.config.ignore_exceptions.include?(exception.class)
+ notify_of_exception(env, exception)
+ end
+
+ raise exception
+ end
+
+ private
+
+ def notify_of_exception(env, exception)
+ controller = env['action_controller.instance'] || MissingController.new
+ Failurous.notify(exception, controller)
+ end
+ end
+end

0 comments on commit 5de58aa

Please sign in to comment.