[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling multiple exceptions



Chris Double wrote:

>>The problem is that code can result in a number of exceptions, whether
>>it establshes a connection (and stop receiving data) or doesn't.  In
>>java you can have multiple catch blocks on a try block.  As I
>>understand it the block() is like a try block, so how do I have
>>multiple exception blocks?
> 
> Something like:
> 
>   block()
>     // my code
>   exception(e :: <socket-closed-exception)
>     // handler
>   exception(e :: <connection-failed-exception>)
>     // etc
>   end;


Also note that, unlike in Java, if you want to do the same thing with 
several exceptions, you can say

   block()
     // my code
   exception(e :: type-union(<socket-closed-exception>,
                             <connection-failed-exception>))
     // handler
   end;

:-)

Hugh