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.

See also  Does It Make Sense to Splurge on a Laptop?

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist