Option A:
public void method() {
try {
// some operation that throws FirstException
} catch (FirstException ex) {
throw new RuntimeException(ex);
}
try {
// some operation that throws SecondException
} catch (SecondException ex) {
throw new RuntimeException(ex);
}
}
Option B:
public void method() {
try {
// some operation that throws FirstException
// some operation that throws SecondException
} catch (FirstException ex) {
throw new RuntimeException(ex);
} catch (SecondException ex) {
throw new RuntimeException(ex);
}
}
Which one is better and why?