Is there a way to drop into debug view mode after an exception?

Hi,

I know how to use Rails debugging via entering a “debugger” statement.

Question - Is there a way however to drop into the debugger mode after
an exception has occurred? and effectively back back one step just
prior to the exception occurs, and then you can query the variables
etc. That is then a way to (a) drop from “script/server” mode to
“debugger” shell, and (b) go back to the point just before the
exception?

Thanks in advance