When I have a method like this:
public static void foo(String param) throws IOException { try { // some IOoperations if (param.isEmpty()) { throw new IOException("param is empty"); } // some other IOoperations } catch (Exception e) { /* handle some possible errors of of the IOoperations */ } } And when the IOException ("param is empty") is thrown, it is catched by the try-catch in that body. But this exception is meant for the caller of this method. How can I do this properly? Is there something "pure-Java" to do this or do I have to create an other type of Exception which is not an instance of IOException to avoid the try-catch body will handle it?
I know you would suggest to use a IllegalArgumentException in this case. But this is a simplified example of my situation. In fact the Exception I throw is an IOException.
Thanks