I have a separate JAR library with a set of methods that throw custom exceptions, for example:
public String methodName() throws CustomException {
}
Then I add the JAR to the classpath and reference the library method in the try statement in the source code:
try {
DemoClass demoClass = new DemoClass ();
demoClass.methodName()
} catch (CustomException e) {
}
The following compilation error is saved in the above code snippet:
A custom exception never throws itself into the body of the corresponding try statement
If the method is in a local context (not packaged in a JAR), the code works. So my question is: is it possible to "throw out" user exceptions from JAR libraries?
source
share