Article View: borland.public.cppbuilder.nativeapi
Article #14537Re: Get exception info as return code
From: Martin Casatti
Date: Sat, 09 Aug 2003 16:33
Date: Sat, 09 Aug 2003 16:33
39 lines
2557 bytes
2557 bytes
Helmut Giese wrote:
> Hello out there,
> we have an environment, where a master program executes other
> programs. In case of error (in these "other programs") we want to tell
> as precisely as possible what went wrong - including the kind of
> exception thrown, if any.
>
> To test this feature, we have a mini program which just causes an
> exception (see raiseex.c below). We start it using CreateProcess and
> obtain its exit code with GetExitCodeProcess - this all works.
>
> The problem is, that (Builder 5 compiled) raiseex always returns -1 -
> no matter what exception it raises. A customer provided a version
> compiled with VC++, and this returns 0xC0000093 to our "master
> program" (like expected).
>
> What do we have to do to have a program return specific exception
> information? Some kind of exception handler? Some compiler option?
>
> Any hint will be greatly appreciated.
> Helmut Giese
>
> ---------- raiseex.c -----------
> #include <windows.h>
>
> int main( void)
> {
> int cmd = EXCEPTION_ACCESS_VIOLATION;
>
> /* Make sure the GPF dialog doesn't popup */
> SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
> /* SMASH! */
> RaiseException( cmd, EXCEPTION_NONCONTINUABLE, 0, NULL);
>
> /* NOTREACHED */
> return 0;
> }
>
Catch the exception at the application level. Once there return the error code you want.
Technical Details
Message-ID:
<___DBBD19DA@skynet>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!skynet!anonymousReferences:
<3eff2d61.13577729@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2009127fe7e4b0b2 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-10 17:47:19 PST Date: Sat, 09 Aug 2003 13:33:27 -0300 Lines: 41 From: Martin Casatti <mcasatti@skynet> To: borland.public.cppbuilder.nativeapi Message-ID: <___DBBD19DA@skynet> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030528 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Get exception info as return code References: <3eff2d61.13577729@forums.borland.com> In-Reply-To: <3eff2d61.13577729@forums.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 200.42.156.34 X-Trace: newsgroups.borland.com 1060562661 200.42.156.34 (10 Aug 2003 17:44:21 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!skynet!anonymous