Article View: borland.public.cppbuilder.nativeapi
Article #14991Re: Exception handling
From: Rob
Date: Fri, 25 Jul 2003 11:24
Date: Fri, 25 Jul 2003 11:24
48 lines
2810 bytes
2810 bytes
"Yahia El-Qasem" <Yahia.El-Qasem@mgh.metro-ag.de> wrote in message
news:3f2017c2@newsgroups.borland.com...
> > try and catch are the standard C++ method of managing exceptions.
> >
> > __try, __except, and __finally are related to the operating system
> > exceptions.
> >
> > The two types of exceptions, and they way they are handled, are
> > actually distinct.
> >
> > As OS exceptions are usually something that can be avoided by
> > good coding, it is probably better to design your software so
> > they don't occur in the first place. If you feel you really must
> > catch them, the recommended approach is to catch OS exceptions
> > (using __except) and have the handler throw an appropriate C++
> > exception.
>
> You are absolutely right - I try usually to avoid such things by better
> design / coding...
> The problem occurs usually with third party components / OLE Automation
> Servers I have to use...
> They do whatever they do ok but sometime throw OS exceptions - I need to
> catch these...
> Otherwise my whole app behaves strange ( if I don't catch them )...
>
> Even when using __except etc. with some exceptions it seems impossible to
> catch them - esp. when they occur inside OLE Automation servers I use...
> And this really makes my app reacting really strange when this happens...
>
> Is there any way making sure that really all exceptions get caught ?
>
The most obvious way I can think of, if you simply want to ignore the
OS exceptions is
__try
{
// code that throws system exception
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
If you want to get information on the actual exception that
has been raised, look up GetExceptionInformation() in the
online help.
Technical Details
Message-ID:
<3f211485@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f1ee3c0@newsgroups.borland.com> <3f1fcbe4@newsgroups.borland.com> <3f2017c2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,9958034f094baec7 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-25 04:39:46 PST From: "Rob" <nospam@nonexistant.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f1ee3c0@newsgroups.borland.com> <3f1fcbe4@newsgroups.borland.com> <3f2017c2@newsgroups.borland.com> Subject: Re: Exception handling Date: Fri, 25 Jul 2003 20:54:17 +0930 Lines: 50 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 211.26.115.103 Message-ID: <3f211485@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059132549 211.26.115.103 (25 Jul 2003 04:29:09 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail