class TestException extends Exception
{
private String exceptionCode;
private String exceptionMessage;
@Override
public String toString()
{
return "TestException [exceptionCode=" + exceptionCode + ", exceptionMessage=" + exceptionMessage + "]";
}
}
try
{
TestException testException = new TestException();
testException.exceptionCode = "Test exception code";
testException.exceptionMessage = "Test exception message";
throw new IOException("Io message", testException);
}
catch (Exception e)
{
logger.error("Error message ", e);
java.util.logging.Logger.getAnonymousLogger().log(java.util.logging.Level.SEVERE, "Error message", e);
}