Receiving Unhandled exception and unreachable catch block in the same line of java code

230 Views Asked by At

In the following code I receive 2 errors:

  1. Unhandled exception type ValidationException at line xxx

  2. Unreachable catch block for ValidationException. This exception is never thrown from the try statement body at line yyy

public void validateExistingTemplate() {
  try{
  dummyObject.validate();   //line xxx
  }
  catch(ValidationException e){ // line yyy
      //to do 
  }
}

try {
List emailOptionsList = someHelper.someMethod(SomeClass.class, 
    criterion, null, false);
if(emailOptionsList.size() > 0) {
  operationContext.addErrorMessages(new Message("ERROR_MESSAGE"));
} 
} catch (ServiceApplicationException ex) {
  throw new ValidationException();
}
}

I am not sure how to get rid of this. what am i doing wrong here?

0

There are 0 best solutions below