Is there any way to start the Ruby debugger on exception?

debugging, exception, ruby

Solution

I stumbled across this page:post-mortem debugging. Doing this:

Debugger.start(:post_mortem => true)

gets me where I want to.

Problem

Is there any way to start the/a Ruby debugger whenever the code throws an exception, without me wrapping the code like this: ``` begin #do something rescue debugger end ``` I'd like to have it in such a way that if the `do something` part raises an exception, the debugger will start. It would be nice not having to modify the code to add begin rescue blocks all over.

Original source