Skip to main content
gamedev.net
🔒 Locked

[web] Javascript error handling

Started by EvilCrap 3 replies 1.2k views
Original Post
EvilCrap
EvilCrap
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?
konForce
konForce
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.<br><br>With a proper browser setup, you'll not need to add any debugging-style error handling yourself.
a_bertrand
a_bertrand
with javascript you can use the try / catch syntax as in Java:

try
{
some faults;
}
catch(e)
{
alert('Something wrong here.');
}
---http://www.nowhere-else.org
markr
markr
Unfortunately, in my experience, I've generally been unable to get useful javascript errors out of IE.<br><br>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. <br><br>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.<br><br>Venkman (The Mozilla javascript debugger) is of course much better, but you can't use it to debug IE javascript problems (obviously).<br><br>Of course try and catch are available, but I don't think the error object contains many useful properties.<br><br>Despite all these problems however, IE's javascript error handling is still better than Konqueror, which appears to just totally ignore javascript errors.<br><br>Mark
Zanthos
Zanthos
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.<br>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.