Visual Basic 6 -Error handling and Debugging and File Input/Output
Error Handling enables programmers to write clearer, more robust, more fault-tolerant
programs. Error handling enables the programmer to attempt to recover (i.e., continue
executing) from infrequent fatal errors rather than letting them occur and suffering
the consequences (such as loss of application data). If an error is severe and
recovery is not possible, the program can be exited "gracefully"-all
files can be closed and notification can be given that the program is terminating.
The recovery code is called an error handler.
Error handling is designed for dealing with synchronous errors such as an attempt
to divide by 0 (that occurs as the program executes the divide instruction). Other
common examples of synchronous errors are memory exhaustion, an out-of-bound array
index, and arithmetic overflow. Error handling provides the programmer with a
disciplined set of capabilities for dealing with these types of errors.
Error-handling code varies in nature and amount among software systems depending
on the application and whether or not the software is a product for release. Products
tend to contain much more error-handling code than is contained in "casual"
Usually, error-handling code is interspersed throughout a program's code. Errors
are dealt with the places in the code where errors are likely to occur. The advantage
of this approach is that a programmer reading the code can see the error handling
in the immediate vicinity of the code and determine if the proper error handling
has been implemented.
The problem with the scheme is that code in a sense becomes "polluted"
with error handling. It becomes difficult for a programmer concerned with the
application itself to read the code and determine if the code is working is correctly.
Error handling often makes the code more difficult to understand and maintain.
When Error Handling should be used
Error handling should be used to process only exceptional situations, despite
the fact that there is nothing to prevent that programmer from using errors as
an alternate form of program control.
This lesson explains about error handling and debugging in easy steps with
quick examples. For more in-depth lessons in Error Handling click