jeudi 3 août 2017

How to store an exception

I want to throw an exception and to display it. In my IF block I throw the exception. Do I have to store the exception to pass it as a variable in the method which precedes.

if(count !=0) {
  throw new Exception();
  eventLogger.logError("The count is not zero",e)
}
else{
    // do something else
}

The logger has Throwable error as a parameter.

logError(String description, Throwable error);

How can I pass the exception I thrown to this method

Aucun commentaire:

Enregistrer un commentaire