🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #3010

Re: Error Handling in Windows Programs

#3010
From: CADSI
Date: Tue, 04 Jun 1991 17:57
46 lines
2758 bytes
From article <1991Jun3.025142.4227@mnemosyne.cs.du.edu>, by ebergman@isis.cs.du.edu (Eric Bergman-Terrell):
> 
> 
[ stuff deleted ]
> 1.	Are Catch() and Throw() reasonable to use when one of your program's
> 	commands has failed and you want to go back to the main event loop?
> 
> 	For example, your main event loop calls a routine that calls a 
> 	routine that calls a routine that ,..., calls a routine that fails
> 	and you just want to quit what you're doing and let the user make
> 	another menu selection.
> 
> 	In other words, are Catch() and Throw() reasonable to use & safe?
> 	What are the non-obvious pitfalls???

I use Catch and Throw in order to catch math (matherr.c) problems.  It works
for me.  They have recovered from some VERY deep recursions and I Still
have no problems.  I Do personally hate the way they declare the buffer.
In the Catch call you're supposed pass a CATCHBUF pointer.  Thing is,
a CATCHBUF is already a pointer since its just an array for register
variables.  Thus, if you try Catch(&catchbuf), MS C compiler complains
about superfluous & on array.  You'd think MS would have handled this
a little better.
> 
If you are planning to  jump back to a spot where a Menu was popped up,
it probably won't work, since the menu would no longer be popped up.
However, If you put the Catch call at the top of a message "switch",
it works ok.

> 2.	I am dreading having to check the error codes from every single
> 	Windows function that my (30,000 line) program calls.  Are there
> 	alternatives that will still catch every failure?  For example, 
> 	is there a mechanism that would "call the specified function if
> 	failure X occurrs".
> 
> 	For example, my program is graphically intensive.  It would be way
> 	cool to give Windows the address of a function to call whenever a
> 	request for a handle to a new gdi object failed...  

You need to redefine the 'new' operator (use C++).

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|
Technical Details
Message-ID: <1991Jun4.175700.11224@ccad.uiowa.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!ns-mx!ccad.uiowa.edu!cadsi
References: <1991Jun3.025142.4227@mnemosyne.cs.du.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!ns-mx!ccad.uiowa.edu!cadsi
From: cadsi@ccad.uiowa.edu (CADSI)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Error Handling in Windows Programs
Message-ID: <1991Jun4.175700.11224@ccad.uiowa.edu>
Date: 4 Jun 91 17:57:00 GMT
References: <1991Jun3.025142.4227@mnemosyne.cs.du.edu>
Organization: CAD-Research, U. of Iowa, Iowa City, Iowa
Lines: 46