Sunday, April 29, 2012

Raising Exceptions in Components

So, instead of calling the MsgBox function from a component when an exception occurs, the proper thing to do is to use the Visual Basic Err object's Raise method, and hope that the code that the client code using the component has an appropriate error handler defined. Basically, when it comes to handling exceptions, COM components should have the "Something unexpected has happened and I can't continue processing, so whoever called me needs to do something about it" attitude. .. I suggest that all errors that a given class might raise be defined as Public Enums in the class module's General Declaration section.
http://www.informit.com/articles/article.aspx?p=22679&seqNum=5

No comments:

Post a Comment