Chapter Twelve
Error Messages

Trying to Interpret Those Error Messages That Appear When Things Go Wrong

It happens all the time, unfortunately, unless you are one of those folks who are perfect...

An impudent dialog box appears, covering half the screen, informing you that you've screwed up.

Some of these are pretty easy to understand and are a real help in figuring out what you did wrong.

For example, if the message has something to do with "unterminated string", you can figure that you screwed up your double and single quotes in a string, or you forgot that you can't make a code line more than 50 or 60 characters long.

Many times the error message will give a JavaScript line number. However, this line number is at best an indicator pointing you close to where the problem occurred, since the compiler line counter generally will bear little resemblance to the way you have written your script.

So if it says there's an error on line 65, you will want to start looking at about line 50 for the error.

There are other error messages that may point you to where the error is occurring by the way they are worded.

For example, if the message is "Window.document searcher.text has no properties", you can be pretty sure that either the form named "searcher" wasn't found with an element named "text" in it or you gave it the wrong frame pane to look in, or the form wasn't yet loaded before it looked for it.

You may be saying to yourself about now, "Well, what good is the error message?" First, it tells you that you have a problem, and second, it helps you narrow down what the problem is, most of the time. That's helpful. Really...

© Copyright 1997, John H. Keyes