Rollback the transaction when an error occurs