I have a class whose methods require that a certain class field exists correctly. That class field is set in the constructor and it's read from a config file, and it may or may not get the correct data from that config file. If the data is incorrect, it will have the wrong data in the class field and the class method will throw an exception.
If that happens, what I want to do is run the method again but with a different call to the class constructor. Is this something that is reasonably handled in a try:catch? Because the method MAY throw the same exception even with the correct class field. So what I want is to have the first time the method is called, the exception is caught and then the method run again. But on the 2nd run if the exception is thrown I want it to propagate. So:
try:
MyClass().method()
except MyException:
MyClass(True).method()
Is there an obvious flaw to this? Or a better way to do this without using counters, or flags, or other ugly helper objects?