Re: Handling multiple exceptions in one exception handler block
- From: "Ingo R. Homann" <ihomann_spam@xxxxxx>
- Date: Mon, 17 Jul 2006 11:14:24 +0200
Hi,
Adisht wrote:
Hi all,
I can anyone send me an example of how to catch 2 exceptions but handle
them together ?
Thanks,
Adi
Unfortunatly, (if the two exceptions do not have a supertype which the other exceptions do not have) this is not possible. You can only extract your code to a method:
try {
...
} catch(Exception1 e1) {
error(e1);
} catch(Excpetion2 e2) {
error(e2);
}
(Another possibility would be to catch the general class "Exception" and to do an instanceof-check, but this is not a good idea IMHO.)
Ciao,
Ingo
.
- Follow-Ups:
- Re: Handling multiple exceptions in one exception handler block
- From: Luc The Perverse
- Re: Handling multiple exceptions in one exception handler block
- References:
- Prev by Date: Re: The Right Level of Patterns
- Next by Date: Re: exe within a jar file
- Previous by thread: Handling multiple exceptions in one exception handler block
- Next by thread: Re: Handling multiple exceptions in one exception handler block
- Index(es):
Relevant Pages
|