You need not know that logic :) All that I expect is a undeploy() call on my visitor which failed during deploy. And my visitor's undeploy() will have the knowledge of revert-doMyWork();
At the end it all depends on impl details; e.g. at which step is the deployment used enough so you can do proper revert
Our code assumes the least logic possible, meaning if the error occurred, you didn't do much, hence no need to actually do undeploy.
But you can simply "fix" this generic behavior by impling this logic into your custom visitor.