Welcome to Web-News
A Web-based News Reader
Subject Re: global exceptions handler
From Vathix <vathix@dprogramming.com>
Date Fri, 29 Oct 2004 21:17:05 -0400
Newsgroups digitalmars.D

On Fri, 29 Oct 2004 12:25:54 +0200, Asaf Karagila <kas1@netvision.net.il>  
wrote:

> yeah, i understood that earlier from your posts,
> but what if its an unexpected exception ?
> the only way i can think of now is to install the handler using
> the winapi SetUnhandledExceptionFilter, but i sorta hoped there would be
> something like that built-in the language..
>
> - Asaf.

catch{} or catch(Object o){}  will catch ALL exceptions. Even the Win32  
exceptions are converted internally by D. Try something like this:

try
{
    // stuff
    *(cast(int*)0) = 0; // test
}
catch(ExpectedException e)
{
    // something
}
catch(SomeOtherExpectedException e)
{
    // something else
}
catch(Object e)
{
    writef("Unexpected exception: %s\n", e.toString());
}

Recent messages in this thread
 
-# Re: global exceptions handler Sai 28-Oct-2004 12:43 am
|-# Re: global exceptions handler Asaf Karagila 28-Oct-2004 11:43 am
|.-# Re: global exceptions handler Regan Heath 28-Oct-2004 04:32 pm
|..-# Re: global exceptions handler Asaf Karagila 29-Oct-2004 06:25 am
|...|# Re: global exceptions handler (Current message) Vathix 29-Oct-2004 09:17 pm
|...-# Re: global exceptions handler larrycowan 29-Oct-2004 10:25 pm
|....\# Re: global exceptions handler Asaf Karagila 30-Oct-2004 04:30 am
-# Re: global exceptions handler Asaf Karagila 26-Oct-2004 03:47 pm
.-# Re: global exceptions handler Regan Heath 26-Oct-2004 04:29 pm
..\# Re: global exceptions handler Asaf Karagila 27-Oct-2004 12:29 am