Properly handle database rollbacks when exceptions are thrown