Skip to content

October 15, 2009

Internet Explorer Debugger – The way it reports errors is misleading

by Joe Kuan

ie_logoOne of my many annoyances of IE is the way it reports Javascript errors. It is misleading and it brings confusion. One of the typical errors is ‘Object Expected’, it generally means reference to an object is undefined. The common cause is a function hasn’t been declared or some syntax errors within.

In my opinion, if you enable Javascript debugger, then it should stop loading any Javascript code as soon as it comes across the very first error. For example, we have a Javascript syntax error.

<script language="javascript" type="text/javascript">
<!--
function test() {
  alert('This is a test';
}

-->
</script>
</head>
<body>
<a href='#' onclick='test()' >Click me</a><BR>
</body>
</html>

As you can see, there is a missing close bracket in the function test. When a Javascript error occurs, IE asks the user whether (s)he wishes to launch a debugger. When the user clicks Yes, the debugger automatically zooms the user to the where the Object Expected error occurs.

IE debugger

This is a very bad decision indeed. It should always brings the user attention to the very FIRST error it detects, not the last one or to the point it cannot go further. It confuses the user that this is the root of the errors which is clearly not. There is nothing wrong whether the debugger points to. Whatever I do at this error, it will not go away, not unless I fix the previous ones.

If the syntax error function is located in external Javascript source file, the debugger is able to report the error in the source file but still prompt the user to the last error.

However, this is only a simple example. Imagine you have multiple Javascript source files to load and object methods on top of each other. Then it may not be that obvious.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: