Che Kofif
Che Kofif

Reputation: 861

How can I log Javascript errors and report them without using Javascript?

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

Upvotes: 4

Views: 442

Answers (3)

Anurag
Anurag

Reputation: 141909

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.

Upvotes: 3

Alex
Alex

Reputation: 1337

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.

Upvotes: 1

Alex Wayne
Alex Wayne

Reputation: 187262

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
}

Upvotes: 3

Related Questions