Catching an exception that is nested into another exception

后端 未结 7 1581
暗喜
暗喜 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:41

    I doubt, but you can check with instanceof if the exception is of the correct type.

    Edit: There should be a reason that the nested exception is wrapped, so you have to ask yourself what is the purpose of catching the nested one.

提交回复
热议问题