Jump to content
  • Advertisement
Sign in to follow this  
EvilCrap

[web] Javascript error handling

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
with javascript you can use the try / catch syntax as in Java:

try
{
some faults;
}
catch(e)
{
alert('Something wrong here.');
}

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!