I have two functions (ServerSocket.accept() and Socket.setSoTimeOut()) which are throwing IOException and SocketException which is extending IOException.
How can I know which function throw this exception if I’m catching IOException?
Should I call these functions on separate try/catch blocks? Or there is a more proper way to do that?
How about having two catch blocks, one for SocketException and the other one for IOException. You can then tell which method call failed by the catch block that gets executed.
Note: The catch block for SocketException should come first for the code to be valid and compile.