Requirement: If there are any exceptions, call a method that re verifies data
My implementation:
private void one() {
try {
//Valid data
}catch(Exception e) {
two();
}
}
private void two() {
//Process data with another input
//On entry,
one();
}
I realize that my usage is incorrect. How should I be handling this?
You can do it exactly the way you suggest, using recursion. I don’t see what the problem is. Personally, using a loop is usually simpler than using recursion. I wouldn’t just catch all Exception’s however. You are likely to want to handle different exceptions differently.
or even