views:

51

answers:

3

Hi, My webapp currently employs a JS based error logging system for reporting JS error on the client side. The problem with logging your error using javascript is just that - we are using a technology to monitor problems in that same technology. Easily an error in the JS could prevent the logging from occuring.

I was wondering if anyone has an idea how we could log and report client side errors without relying on out own Javascript code.

thanks

+2  A: 

we are using a technology to monitor problems in that same technology

Don't we always do that. Have you ever done error and exception handling in a language other than the one you're working with?

Use window.onerror callback. Will also catch syntax errors. Or try catching the error as @Squeegy suggests.

Anurag
I'm not talking about error handling... I'm talking about logging.If a fatal error happens in some JS code- it could very easily prevent the JS from sending it's report back to our servers...But thanks anyway :)
Che Kofif
+3  A: 

Nope. But you can use a try / catch block to get out of javascript error that would otherwise stop execution.

try {
  stuff.that('raises').error();
} catch(e) {
  // send e via ajax
}
Squeegy
Thanks, I know how to handle JS errors, I'm just looking for a way to disconnect the reports from the JS.
Che Kofif
Well what else would you use? JS is how webpages handles dynamic content. There is no other tech that would allow you capture this stuff and do something with the result. Even things like flash would have to manipulated through JavaScript. You handle JS errors with more JS, and that's just how it works. But why is this a problem? If I said you could use ruby or C to handle errors, would that really make any difference to your approach?
Squeegy
+1  A: 

Unfortunately, I don't believe that is possible. You will have to use javascript in some form to catch and report the errors, whether it be sending an ajax request, or having users submit a form with the errors in a textbox.

Alex Nolan
The whole idea is to keep users out of the loop :)Thanks
Che Kofif