Comments By: Mikko Rantalainen
-
Why not put the rollback code in the destructor of your database abstraction layer? You're already keeping a stack of open transactions: if the destructor is called (the object is going out of scope) and there're any open transactions, the sensible thing is to rollback all those transactions and then throw an exception telling about the fact.
posted on Jul 6, 2009 at 6:45am | context
That way any exception anywhere (not only exceptions thrown by your database layer) automatically rollback the transactions as required.
