In-Depth
Error Handling
- By Martin Nemzow
- July 20, 2001
Simply put, VB error handling is poor due to a lack of global error trapping and management.
A number of third-party tools and freeware address this critical need. Still, the mechanism for error handling in VB is poor because the language is based on objects (modules, forms, functions and procedures) with the result that most objects will require specialized error-handling code, even if it is identical to the code within another object. The old adage of one line of code for error handling for each line of code holds for VB. Fortunately, many things that can go wrong in an application do not go wrong in VB and are addressed by built-in system error messages. However, complex applications that reference Access, ODBC databases on a network, external automation servers and add-in controls do require more error code than the average programmer will be able to add manually.
VB/Rig Pro from Whippleware, Charlestown, Mass., and VB/FailSafe from NuMega Technologies, Nashua, N.H., are the best of the commercial products because they automatically read the application, parse its code at the global, form and function levels, and add error handling code to each function. These tools enable pop up dialog boxes for the users and then redirect the flow of control back to the top of a routine or back to a main menu.
Nevertheless, error detection -- which is easy -- and handling the errors in a mission-critical environment -- which is harder -- becomes yet more complex with network or Internet applications. VBRig and FailSafe augment the sparse and difficult-to-implement "On Error" support in VB and trap errors with a series of pop-up dialog boxes.
Error-handling should be invisible and automatic even for single-user applications. The need for automatic error handling with networked OLE servers and Web applications is more acute because OLE servers cannot have any forms or user input as a design limitation; they really state machines. Applications that include telephony, Internet connectivity or videoconferencing components will not tolerate out-of-band error handling; the call will be terminated and restarted in those cases, if only by exasperated users. That can be expensive or disastrous when an existing customer is lost.
About the Author
Martin Nemzow is a consulting editor for McGraw-Hill Publishing. His company, Network Performance Institute, Miami Beach, Fla., provides enterprise network design and improvement consulting services, markets capacity planning, and develops and markets shrink-wrapped network configuration software tools.