Error Handling Schemes and Assignments
An Error Handling Scheme is a general error handling template designed
for a specific component or procedure. This template completely describes an error
handling configuration: the error handler header, the error handler footer,
if line numbers should be inserted or not and some other options that configure
the automatic insertion/removal process. These templates can be assigned
to different types of Visual Basic components (Classes, Forms, Modules etc.) or
to procedures (members) that match a certain pattern.
CodeSMART comes with a set of predefined error handling schemes that
can be modified in order to reflect your project's error handling needs. Schemes
can be created, modified, assigned and removed through
the CodeSMART Error Handling Scheme Manager.
It is well known that certain procedures or components require specific error handling
schemes. A class module will propagate the error to the client with an Err.Raise
statement instead of displaying a dialog box to the user, a standard form or module
should usually display an error message and/or log the error, a Timer
or Resize event should preferably use an On Error Resume Next error
handling, Terminate events should always use On Error Resume Next
error handling, etc. With CodeSMART you can assign error handling schemes to
components and even to procedures.
To manage error handling schemes:
-
Click Edit Error Handling Schemes entry in the CodeSMART main menu or in the Modifiers popup.
-
Activate the Error Handling Schemes tab in order to display the currently defined error handling scheme templates.
-
Select an existing scheme if you want to modify its contents, to duplicate
it or to remove it. Press Add Scheme to create a new scheme. If
you create a new scheme or modify the name of an existing one be sure to provide
a unique name for it. The name of the scheme represents the scheme identifier
used by CodeSMART when inserting and removing error handling code and error
scheme modifiers.
-
Edit the Header and the Footer section by typing the code that
does the effective handling. The Header and the Footer code can contain CodeSMART
standard parameters
-
Optional. Specify if CodeSMART should insert line numbers before
code statements when the scheme is inserted. If you check this option you must
provide a base number and a step used for numbering. You can also
specify if code lines that do not generate errors (inoffensive statements)
should be skipped and if you want to insert line numbers in the scheme
header and footer.
-
Optional. Specify if you want to change the On Error GoTo 0 statements
to On Error Goto <Label> where <Label> will be replaced
with the text specified in the Label name text box. If this option is
checked the replacement is performed when the error handling code is inserted,
and reverted when the error handling code is removed.
You can explicitly instruct CodeSMART to avoid this replacement for some On Error GoTo 0
statements by placing the special marker after
them onto the same line:
On Error GoTo 0
All the On Error GoTo 0 statements that are followed by this particular
inline comment will be left unchanged.
Note
-
The error handling schemes are stored into the team database. You can
share the same error handling system with other users by sharing the
Team.mdb database.
To manage error handling scheme assignments:
-
Click Edit Error Handling Schemes entry in the CodeSMART main menu or in
the Modifiers popup.
-
Activate the Scheme-to-Element Assignments tab in order to display the error handling scheme assignments.
-
The default scheme (the one that is used for methods that do not have a
scheme modifier) is listed in the Default Assignment list-box.
You can designate a new scheme as default by selecting it from the list.
-
The assignments are divided in two categories:
-
Component assignments: used to specify what scheme should be
used for different component types.
-
Member (procedure) assignments: used to specify the schemes to
be used for procedures that match a certain pattern.
-
Select an existing assignment if you want to modify or remove it. Press
Add Assignment to create a new assignment. If you create a new assignment
or modify the name of an existing one be sure to provide a unique name for it.
-
Edit the assignment's settings
-
For a component assignment, click on the Add Component Type
toolbar button in order to select the Visual Basic component types that
should use this assignment. The Default list entry contains component
types with no assignment defined and it is used to specify which error
handling scheme should be used by default. To remove a component type
from an assignment you should click on the Delete Component Type
toolbar button.
-
For a member assignment, click on the Add Member Filter
toolbar button in order to add a new member filter. For example if you
want to create a filter for the Resize procedure add the "*_Resize"
member filter. To change a member filter click on the Edit Member
Filter toolbar button while and to remove it use the Delete Member
Filter toolbar button.
-
Select the scheme you want to use for the current assignment in
the Error handling scheme combo box.
To manage error handling scheme assignments:
-
Click on the Edit Error Handling Schemes entry in the CodeSMART main menu or in
the Modifiers popup.
-
Activate the General Options tab in order to display the error handling scheme insertion options.
-
Specify if the empty members (that is, methods that contain only comments and empty lines) should be skipped from error handling insertion operations.
-
Specify if the line numbers used in error handling insertion operations should have terminating colon characters or not.
-
You may also instruct CodeSMART to skip methods that already have error handling code, either user-inserted (i.e. manually inserted) or CodeSMART-inserted.
See also
Back To Top
|