function for wrapping a block of ruby code in a exception handler and adding pry