Locating semi random errors

By | August 18, 2006

If you’re a software developer you are bound to have encountered the following story:

Customer: The program that you delivered produces error messages when I run <feature>.

Any error is important so you start up the application and start following the same actions as the user did. And sure, there it is. The application starts generating error messages. Here comes the brainbreaker, during a debugging session the error never appears to occur.

Well I recently had one of those and its hard to track the exact location of the error, even when your log file is telling you exactly were it is. One of the first things I learned was that sometimes compilers add information to debug versions that catches or prevents the exception from happening. Meaning you will never see it unless you have a runtime compiled version.

One of the few options you have left is adding logging lines throughout the code that you expect the error to be in. I know this is a major pain in the ass, but I didn’t see any other way.

If you had an error similar to mine you will find out that it only happens half of the time (I had a null pointer exception on a constructor call). I personally think that Java was punishing me for working to hard.

So the hard lesson learned was that inserting enough logging lines eventually gets you the exact location and sometimes even reason for the error. But it does require you to be very patient, something that I’m apparently missing.

Leave a Reply