devxlogo

Error Handling In A Class Module

Error Handling In A Class Module

To signal errors from within a class method, use the Error.Raise methodand bubble it back up to the server. Check the docs for Error.Raise andthe books online. One caveat is that errors in Class_Initialize and Class_Terminate donot bubble back up. Like errors in an event procedure of a form module,they’re not in the client’s call tree. If they are untrapped, the OLE serverwill terminate abruptly. On an out-of-process server, your client will be left with invalid references.If your server is in-process (an OLE DLL), the situation is much more seriousbecause your client will also terminate abruptly. (When you’re in the sameprocess, your fatal errors are your client’s fatal errors.) Therefore, always protect Class_Initialize and Class_Terminate withbulletproof error-trapping, and never raise errors in them.

devx-admin

Share the Post: