6.1. Building a Robust Application
There are two approaches to error handling. The first is to let the error occur, then do something about it; the second is to prevent the error from occurring. Each has its own merits. Supporters of the first approach argue that most errors occur very infrequently. For example, users of a computer system are by and large well trained and make few data entry errors. Therefore, the extra processing to prevalidate such things as numeric values is a waste of processing time and power; it's more efficient to execute an error-handling routine occasionally than to invoke a validation routine for every entry. On the other hand, supporters of the second approach argue that it's not good practice to allow errors to be generated and that if there are techniques available that prevent an error from occurring, they should be used. A remote server that's offline, for example, could take several minutes to generate an error due to network timeouts, whereas a correctly written validation function could report this in seconds. Furthermore, error-handling routines themselves can be the source of further errors.
I think that each argument has merits. You have to judge for yourself whether to use a "belts and braces" approach within a given procedure or whether the likelihood of an error is so remote that a simple error-handling routine will suffice. Don't forget that adding functionality to a program costs time, which is money. Here, though, is a list of simple ...
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.