Re: is there any good pratice f or error handling in Win32 & COM development?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



This is a subject of debate on several newsgroups and discussion lists. So far, my observation is
that the best arguments (and thus the majority opinion) come from the side that say to limit using
exceptions to "exceptional" situations only. There is a high performance cost to be paid for
handling exceptions (especially on x64). For typical, more expected errors, design your functions
to return error codes (such as HRESULTs) or Booleans (bool or BOOL) whenever possible. Most
importantly, ALWAYS check the return codes from these functions and respond to them as needed --
don't just ignore error results. Sometimes, all that is required is to log or report the error and
move on. More often, though, the error means you should also skip some subsequent step, and quite
possibly short-circuit and return from the calling function with an error code -- quite possibly
just echoing the one that was returned already.

In applications whose design would support this, do your best to preserve the "error stack",
possibly with a linked list or arry of "bubbled up" error codes/messages, so that when the call
stack is popped back down, you have the history to show which errors triggered the subsequent ones
leading to the ultimate failure of the operation. See this collection of articles that talk about
the error-handling APIs and interfaces (like IErrorInfo, ICreateErrorInfo, ISupportErrorInfo) used
in Automation:
Error Handling Interfaces (Component Automation):
http://msdn.microsoft.com/en-us/library/ms221510.aspx
These are good patterns that can be followed elsewhere, as well (not just Automation).

"thinktwice" <memorialday@xxxxxxxxx> wrote in message
news:2358b5bb-bb60-4d9e-978d-340bc15e610f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
like utility c++ class, macros for error handling.
i'm looking for a good pratice to follow to deal with error handling,
is there anyone to recommend, or maybe you have already have your way
to deal with this issue , would you mind share with me? thanks in
advance


.



Relevant Pages

  • Re: firewall setup and whois for blacklisting IPs
    ... I don't use any automation, I just look at the auth ... settings to include illegal user attempts in the security mailing - ... When I used ipfw, I did keep the blocked lists in a separate file, ...
    (freebsd-questions)
  • Re: Using checkboxes and textboxes to create a document.
    ... Adding Automation to your Word forms. ... Many of the answers can be selected from checkbox lists. ... I do not want it to apear in the final Word file. ... The idea is to get most of the information in final format in Word, so my transcriptionist only has to make minor additions and perhaps clean up the format so we have a nice medical history document. ...
    (microsoft.public.word.docmanagement)
  • =?iso-8859-2?Q?Re:_field_=3D_to_?=
    ... addr from the excel sheet as a variable to the link so that if the ... Check 'Paste Link' and select 'Unformatted ... It lists invoice numbers and their amounts, ... Looking at insert/fields I don't know whether to use doc automation, ...
    (microsoft.public.word.tables)
  • Re: [RFC][PATCH] filesystem: VMUFAT filesystem
    ... Lots of superfluous whitespace. ... Again, no error handling. ... You should be able to kill this off, ... list and send multiple times to different lists, ...
    (Linux-Kernel)
  • Re: How do I auto populate a field based off of my list selection
    ... ' Macro created 15-11-97 by Doug Robbins to add the address corresponding to ... Adding Automation to your Word forms. ... Learn more VBA to automate your forms. ... I have two lists now in .doc but it's messy...l: ...
    (microsoft.public.word.vba.general)