The correct way to do this in C++ is to invoke some form of RAII whereby the failure logic happens automatically in an object's destructor.
CleanupObject() : successState( false )
successState = false;
if( successState )
In your code, add something like:
if( operation.fails() )
Your cleanup code must not throw any exceptions. Note here that your operations could throw, and your cleanup would still occur. (Your caller would need to catch.)
Using boost's "Scope Exit" might make it easier still to implement "exit code" that must be run at the end of a scope.