Implemented an API for transaction that does a discard on exception