Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mnemosyne.cs.du.edu!isis.cs.du.edu!ebergman From: ebergman@isis.cs.du.edu (Eric Bergman-Terrell) Newsgroups: comp.windows.ms.programmer Subject: Error Handling in Windows Programs Message-ID: <1991Jun3.025142.4227@mnemosyne.cs.du.edu> Date: 3 Jun 91 02:51:42 GMT Sender: usenet@mnemosyne.cs.du.edu (netnews admin account) Reply-To: ebergman@isis.cs.du.edu (Eric Bergman-Terrell) Organization: Nyx, Public Access Unix (sponsored by U. of Denver Math/CS dept.) Lines: 39 Disclaimer1: Nyx is a public access Unix system run by the University of Disclaimer2: Denver for the Denver community. The University has neither Disclaimer3: control over nor responsibility for the opinions of users. I'm currently adding error handling code to my Windows program (an astronomy simulation/prediction/graphing program, for what it's worth). I've added code to handle the obvious problems, for example: cannot find file printer hasn't been specified printer won't do graphics But I'm wondering how to handle some non-obvious things. So heres' a list of questions: 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??? 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... By the way, I have Petzold, Prog. Ref. and Guide to Programming. I looked in vain for coverage of error handling (beyond testing the results of evry function call). If I missed anything, just send me a page number! Terrell