How to continue program execution even after throwing exception?

前端 未结 5 1351
盖世英雄少女心
盖世英雄少女心 2021-02-05 23:56

I have a requirement where in program execution flow should continue even after throwing an exception.

for(DataSource source : dataSources) {
    try {
        /         


        
5条回答
  •  别那么骄傲
    2021-02-06 00:15

    If an exception occurs on the for(DataSource source : dataSources) while calling dataSources to initialize the iterator, then that exception will not be caught.

    Is that what you mean by "If exception is thrown in the first iteration, flow execution is stopped."?

    If this is the case, then there's nothing else you can do and the loop should not execute any interations.

提交回复
热议问题