"finally" will be executed after your RuntimeException is thrown and before it is processed by another catch upper in the stack.
As your finally just continues, in fact it will do nothing.
The contradiction is between the throw in the catch that will end the loop and the continue.
One approach could be:
boolean exceptionOccured = false;
for(Widget w : widgets) {
if(shouldDoStuff()) {
try {
// Do stuff to w.
} catch(Exception e){
exceptionOccured = true; // do not throw yet.
e.printStackTrace();
}
}
}
if (exceptionOccured) {
throw new RuntimeException("Couldn't do stuff.");
}
The main concern with this approach is you don't know what went wrong.