how to catch nested exception

hello i have this code for sending mail with javamail :

try

{

//code that construct message and attachement

}

catch (AddressException e)

{

log.error("AddressException dans MailToExitAction.createAndSendMail() " + e.toString());

e.printStackTrace();

thrownew ExceptionIS2(e.getMessage());

}

catch (NoSuchProviderException e)

{

log.error("NoSuchProviderException dans MailToExitAction.createAndSendMail() " + e.toString());

e.printStackTrace();

thrownew ExceptionIS2(e.getMessage());

}

catch (MessagingException e)

{

log.error("MessagingException dans MailToExitAction.createAndSendMail() " + e.toString());

e.printStackTrace();

thrownew ExceptionIS2(e.getMessage());

}

When i m not connected to the network, i have this exception :

javax.mail.MessagingException: Could not connect to SMTP host: smtp.fr.oleane.com, port: 25;

nested exception is:

java.net.NoRouteToHostException: No route to host: connect

I would like to know how can i catch the NoRouteToHostException, cause i want a different message when i m not connected to the network ?

Thank you

[1874 byte] By [JusteUneQuestiona] at [2007-11-27 10:05:08]
# 1
On the MessagingException, use getCause() to get the nested exception, then inspect it. You may want to use the instanceof operator to determine whether it is a NoRouteToHostException.HTH
OleVVa at 2007-7-13 0:40:07 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you, ill try this.
JusteUneQuestiona at 2007-7-13 0:40:07 > top of Java-index,Java Essentials,Java Programming...