Maintain Call Stack for Error Tracing

Maintain Call Stack for Error Tracing

I program all reusable components into DLLs or OCXs. To provide a consistent error-handling technique across all my projects, I use the Raise method of the Err object in all these components and display the error only in the code module of first entry?such as Command1_Click. Because an error can be generated several layers deep in the code, I propagate the location of the error using this Raise statement in all my reusable components:

 ThisProcEH:	Err.Raise Err.Number, "ThisProc" & vbCr & Err.SourceExit Sub

This way, the whole call stack is returned to?and can be displayed in?the calling procedure (through Err.Source), making errors much easier to find and solve.

See also  How IoT Tech Will Transform Logistics

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