Eric Hartwell's InfoDabble

Welcome to Eric Hartwell's InfoDabble
About | Site Map
Home Tech Notes Apollo 17: Blue Marble Apollo 17 Flight Journal   Calendars About me  

[True tales from the trenches]

On Error Resume Next

By Eric Hartwell -- Saturday, March 12, 2005

I was instructed to fix a problem that a "star" programmer had discovered with my code. Apparently his VBScript routine was working fine, but he was calling my COM component's functions and they were corrupting the database. Imagine my joy when I started to trace through his code:

Function WorksFine(EmployeeID)
On Error Resume Next
EmployeeRecord = LoadEmployeeData(EmployeeID)
On Error Resume Next
On Error Resume Next
WorksFine = SUCCESS
End Function

As you might expect, sometimes the Calculate function would fail and return one of its many documented error codes -- such as, for instance, when the LoadEmployeeData call failed and returned one of its many documented error codes. What you might not expect was that sometimes the EmployeeRecord object had enough valid data left over from the previous transaction that the SaveEmployeeData call would actually succeed in trashing some unrelated employee's record, before returning with or without one of its many documented error codes.

The other programmer was quite upset when I put error handling into his routine.

It turned out he had written it this way deliberately so he didn't need to write an error handler. This was how he achieved the high productivity that made him a "star" programmer.

Moral: You get what you reward.

Creative Commons License

Unless otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License


Site Map | About Me