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

Error Handling Overview

Writing error-free code is generally considered to be an impossible task. When talking about error handling, in Visual Basic there are two major options.

1. You can leave your code with no appropriate error handling, relying on Visual Basic’s default error handling rules. Theses rules are strict and rather severe: unhandled errors are reported, and then an End statement is issued stopping your code execution and possibly leaving data in an inconsistent state.

2. You can deal with errors effectively by implementing proper and consistent error handling within your code. Unfortunately, if you choose this solution, you must implement the error handling mechanism in almost every procedure or function you are writing. The task of implementing such elaborated error handling is not very easy and if you have done this manually then you probably know that it generally takes more than 10% and up to 25% of the coding time. Writing code the that actually performs the errors handling can get really complex, a few reasons why this can happen being:

  • The error handling code can be different from one procedure to another or from one component to another (e.g. in the Terminate event of a user control you should use the On Error Resume Next statement, in a class module you should use the Err.Raise to propagate the errors to the client application that uses the component, in a standard routine you should eventually report and log the errors that happened etc.).
  • In certain cases you can use line numbering and then include a call to the undocumented Erl function in the error handler to pinpoint exactly the line that caused an error. However, adding line numbers is a task that usually can't be done by manually in a reasonable amount of time, an automated tool being required.
  • You may want to log the generated errors to a log file with meaningful information so you can be able to reproduce the error and determine its cause.
  • You can build a call stack that will list your subs, functions or properties in the exact order in which they were executed before the error occurred.
The CodeSMART Error Handling system was designed to ease the task of implementing error handling code, no matter how complex it may be. Using this robust tool you can automatically insert and remove different kinds of error handling code (for different type of components, for different procedures, for procedures that match a certain pattern), insert and remove line numbers, skip components or procedures you don't want to modify, protect from unhandled exceptions.

See also
Error Handling Schemes And Assignments
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