Re: Handling multiple exceptions in one exception handler block



"Ingo R. Homann" <ihomann_spam@xxxxxx> wrote in message
news:44bb54f5$0$26257$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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:

You could say that having a supertype is the way to do this :) This would
of course suggest that you are the one generating and throwing the
exceptions.

--
LTP

for( Base i : allYourBase)
i.AreBelongToUs();


.



Relevant Pages

  • Re: LSP and Equal()......
    ... >> supertype may be the best we can actually accomplish, ... >but fails for the other because of this difference. ... ways to relax LSP is to add exceptions to the contract. ...
    (comp.object)
  • Re: Handling multiple exceptions in one exception handler block
    ... Adisht wrote: ... I can anyone send me an example of how to catch 2 exceptions but handle ... Then wrote a private method to handle these exceptions ... Am also curious to see if anyone has a neater solution. ...
    (comp.lang.java.programmer)
  • Re: Handling multiple exceptions in one exception handler block
    ... Adisht wrote: ... (if the two exceptions do not have a supertype which the other exceptions do not have) this is not possible. ... (Another possibility would be to catch the general class "Exception" and to do an instanceof-check, but this is not a good idea IMHO.) ...
    (comp.lang.java.programmer)