I am trying to throw a (custom) ImportException from the method importUsers in class UserHelper. I can see in the debugger that the throw clause is executed, but the method, from which the importUsers method is called, never catches the exception.
Here is the method, where the exception is thrown:
public static AccessorValidator importUsers(List<String> data, WebUser actor) throws ImportException {
//(irrelevant code removed)
try {
isSuccess = insertUserData(st, blocks, db, actor);
} catch (Exception e) {
throw new ImportException("Could not insert user on line " + rowCounter);
}
}
Here I try unsuccessfully to catch the thrown exception from execute method in AccessorValidator class:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
//(irrelevant code removed)
try{
av = UserHelper.importUsers(data, admin);
System.out.print("test2");
} catch (ImportException ie) {
System.out.print("testE");
returnMessageValue = ie.getMessage();
} catch (Exception e) {
System.out.print("testE2");
}
The output is "test2", and the code execution never gets to either of the catch blocks. What do I do wrong?