Sign in to follow this  
EvilCrap

[web] Javascript error handling

Recommended Posts

is there anyway in javascript to generate a window.onerror message once youve caught an errorobject? The errorobject doesnt seem too useful. I would like to be able to catch my errors and then let window.onerror catch anything else. is there a way to do this? I mainly like the code line and url provided by window.onerror, which arent provided by errorobject. is there a way to fetch these from somewhere once we have an errorobject?

Share this post


Link to post
Share on other sites
If this is to assist in development, I'd highly suggest you use a browser with a good javascript debugger. Firefox has the best plug-ins (WebDeveloper, etc) I've seen for developing. I think even Microsoft has a javascript debugger for MSIE.

With a proper browser setup, you'll not need to add any debugging-style error handling yourself.

Share this post


Link to post
Share on other sites
Unfortunately, in my experience, I've generally been unable to get useful javascript errors out of IE.

The default javascript error handling system does not seem to give me the correct filename / line number most of the time, which is not terribly helpful.

Of course it's fine if you happen to be running the MS javascript debugger (which isn't very good, but at least gives you the right file / line number), but some errors are reported by other people in IE, in which case it's pretty much a lost cause.

Venkman (The Mozilla javascript debugger) is of course much better, but you can't use it to debug IE javascript problems (obviously).

Of course try and catch are available, but I don't think the error object contains many useful properties.

Despite all these problems however, IE's javascript error handling is still better than Konqueror, which appears to just totally ignore javascript errors.

Mark

Share this post


Link to post
Share on other sites
I gave up on trying to programatically retrieve error information from javascript, it was inherantly difficult, and with IE giving me bunk line numbers and filenames, I switched to Firefox for my JS antics, the JS Console provides me with correct error messages, line numbers, and filenames, and Venkman is a life saver. IE does try and use the .NET script debugger, but it's almighty bulk and lack of speed is a bit off-putting.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this