Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'sinatra/base'
- module Sinatra
- # module to catch Sinatra errors and send a email
- module ExceptionMailer
- def initialize(app)
- @app = app
- # set parameters here..
- yield self if block_given?
- end
- def call(env)
- status, headers, body =
- begin
- @app.call(env)
- rescue => error_raised
- # TODO don't allow exceptions from send_notification to
- # propogate
- send_notification error_raised, env
- raise
- end
- [status, headers, body]
- end
- private
- def send_notification(exception, env)
- puts "SENDING NOTIFICATION for :#{exception}"
- end
- end
- register ExceptionMailer
- end
Add Comment
Please, Sign In to add comment