TRANSFORMATIONS settings: Error Handler



Check the Protector box to protect your project from errors.

Error Handlers

A local error handler is a specific routine added at the end of each procedure, that is called whenever an error is encountered (branched with On Error Goto). You may edit the local error handler directly in the right pane.
Note: you may use the following variables added by VB Watch to describe the error: VBWPROJECT, VBWMODULE, VBWPROCEDURE, as well as the VB Err object. Also, Erl contains the error line number (or 0 in case this line doesn't have a number). See Example.

This routine may in turn call a global error handler: when the code executed by the local handler is too large to be written in each procedure, it is recommended to centralize it in external procedures.
These procedures are contained in one or several modules, forming what's called a global error handler, and VB Watch includes them when instrumenting your project.
Global handlers are defined in the \VB Watch 2\Templates\VB6\Protector\Global Error Handler\ subdirectories. VB Watch will add to your project all code modules found in the selected subdirectory; in the example above, it will add \VB Watch 2\Templates\VB6\Protector\Global Error Handler\Send Mail (Full report)\*.*.
- to edit the files of a global handler, use the link provided in the right pane
- to create a new global handler, create a new subdirectory under \VB Watch 2\Templates\VB6\Protector\Global Error Handler\ and transfer source files in it.

It is highly recommended to read the related VB Watch Protector Specifics topic.


Line numbers

Check the Add line numbers box if you wish to pinpoint errors to the exact line location in your code.

Check the Preserve line numbers box if you already have some line numbers (not labels) in your code that are referenced by Goto or On Error GoTo 's statements.


Variable dump

Select this option if you wish to include a variable dump file in the error report. The variable dump file contains the value of all local variables (of the failing procedure, including call parameters), module variables and/or global variables (including Forms with their controls) at the time of error. This includes arrays, user-defined-types and objects as well.

Exclude variables from report: you can list here the names of the variables that you don't wish to include in the dump.

Warning: the variable dump feature requires specific additional code to work porperly. You must use it in conjunction with a local error handler with variable dumping routine and a compatible global error handler. Thus, it is clearly recommended to use the default templates and plans, or modify a copy of them.



This allows trace to file the procedure calls (with or without parameters value) and/or each line execution, which may be very useful sometimes to see the path your program took until the error, and what was the call stack at this moment.


Initialization code

The Initialization code will be executed at startup (Sub Main or Form Load). This was designed to set which features should be turned on or off. For example, you may not want to activate by default the trace line feature which is time consuming, but only depending on the command line or a value in registry.