You are here: AxTools > CodeSMART 2007 for VB6 > Documentation > User's Guide > Error Handling > Error Handling Schemes and Assignments
While browsing this page, why not start downloading the evaluation setup kit (direct download, no questions asked).

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:

  1. Click Edit Error Handling Schemes entry in the CodeSMART main menu or in the Modifiers popup.
  2. Activate the Error Handling Schemes tab in order to display the currently defined error handling scheme templates.
    Error Handling Schemes Manager
  3. 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.
  4. 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
  5. 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.
  6. 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 'CSEH: Skip marker after them onto the same line:

    On Error GoTo 0 'CSEH: Skip

    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:

  1. Click Edit Error Handling Schemes entry in the CodeSMART main menu or in the Modifiers popup.
  2. Activate the Scheme-to-Element Assignments tab in order to display the error handling scheme assignments.
    Error Handling scheme assignments
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. Select the scheme you want to use for the current assignment in the Error handling scheme combo box.

To manage error handling scheme assignments:

  1. Click on the Edit Error Handling Schemes entry in the CodeSMART main menu or in the Modifiers popup.
  2. Activate the General Options tab in order to display the error handling scheme insertion options.
    Error Handling General Option tab
  3. Specify if the empty members (that is, methods that contain only comments and empty lines) should be skipped from error handling insertion operations.
  4. Specify if the line numbers used in error handling insertion operations should have terminating colon characters or not.
  5. 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
Error Handling Overview
Error Handling Scheme Modifiers
Inserting and Removing Error Handlers
Inserting and Removing Line Numbers
Inserting and Removing Line Numbers from Command Line
Exception Handling Basics
Adding and Removing the Exception Handling Module

Back To Top

Copyright © 2008 AxTools - CodeSMART 2007 for VB6 - Error Handling