Re-throw exceptions in Java
void methodWithException() throws Exception {
try {
throw new Exception("test exception");
}
catch (Exception e) {
//implementation of any partial processing
//and send error to the calling code
throw e;
}
}
try {
methodWithException();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
- Log in to post comments