exc/exception_intercept

Here's a neat way to intercept exceptions without rescuing them and rethrowing them (which doesn't work properly on Ruby 1.6).

E.g.:

  class MyException < Exception
    def initialize
      super "Foo!"
    end
  end

exception_intercept( proc { raise MyException }, proc { |exc| case exc when MyException puts "Got the exception!" else puts "UH OH!" kill_exception # don't let this exception propogate further end } )

Public Methods

exception_intercept(main_block, rescue_block)

kill_exception

class KillException < Exception