It smells of bad design for me. General rule: exceptions should not be used for flow control. There are a number of reasons for this; namely, there are usually better / more reliable methods that can be used to test things before exceptions are thrown, and also reduces efficiency.
However, just for the sake of argument, you can do something like the following:
while (true) { try { // do stuff here } catch (MyException) { continue; } // all is good break; }
Again - this is not recommended. I would be happy to offer something better if you could provide a little more context / examples /
Noldorin
source share