Catching an exception that is nested into another exception

后端 未结 7 1605
暗喜
暗喜 2020-12-05 10:18

I want to catch an exception, that is nested into another exception. I\'m doing it currently this way:

} catch (RemoteAccessException e) {
    if (e != null          


        
7条回答
  •  被撕碎了的回忆
    2020-12-05 10:25

    You can do as below:

    catch (RemoteAccessException e) {
        int index = ExceptionUtils.indexOfThrowable(e, MyExcetption.class)
        if (index != -1) {
             //handleMyException
        } else {
        }
    }
    

提交回复
热议问题