I have the following code
try {
// code
} catch (Exception1 e1) {
if (condition) {
//code
} else {
throw e1;
}
} catch (Exception2 e2) {
if (condition) {
//code
} else {
throw e2;
}
}
How can I use a private method to modularize the if-else block in both the catches.
More specifically, if i use a method how to pass the different exceptions to the method and throw them appropriately?
I followed this link, but did not understand how to pass and throw the right exceptions.