So, I assume that something about your code makes obvious decisions difficult, maybe sites with method calls are levels or two down or not at the same level? What exactly prevents you from just holding the counter?
In any case, you need to either count the calls, or use several try blocks, or do it, and define your own exception that contains the missing information (and the old exception, because it's a subclass), and then change it.
Perhaps you could subclass the object using the exception method to wrap the method call and implement a counter?
source share