Add backtrace logging for caught exceptions