I have a requirement where in program execution flow should continue even after throwing an exception.
for(DataSource source : dataSources) {
try {
/
The logic you have there now does exactly that. If the exception puts DataSource
into an invalid state, the next attempt to use the iterator may throw a different exception, but that's a different matter and something specific to DataSource
(so you'd have to look at whether DataSource
lets you do something to deal with that other invalid state in some way). But in the general case, you're doing it right.