Monkey patch Exception class

What I want to achieve is, is that I can hook into the Exception class
of Ruby so that I can trigger special logging events, when an exception
occurs.

I could easily define custom error classes, but I would like to take a
more general approach.

Does someone have advice on how to do this?

Thanks!

···

--
Posted via http://www.ruby-forum.com/.

or you can run with `ruby -d`...

···

On May 14, 2013, at 16:12 , Sebastian Wy <lists@ruby-forum.com> wrote:

What I want to achieve is, is that I can hook into the Exception class
of Ruby so that I can trigger special logging events, when an exception
occurs.

So, this seems to work:

class Exception

  def initialize(*args)
    puts "initialize"
  end

end

The text gets printed out on every exception. I don't how ugly this
solution is and especially how stable, but the functionality seems to be
given.

···

--
Posted via http://www.ruby-forum.com/.

Ryan Davis wrote in post #1109018:

···

On May 14, 2013, at 16:12 , Sebastian Wy <lists@ruby-forum.com> wrote:

or you can run with `ruby -d`...

Hi!

This would theoretically be an option, but I would want to pack the
functionality into a Gem, so other users can hook it into their
applications, and thus this would not be an option.

--
Posted via http://www.ruby-forum.com/\.