Skip to content Skip to sidebar Skip to footer

Redirect Javascript Syntax Errors And Console.log To Somewhere Else

I'm trying to send whatever would normally appear in the javascript console to my own custom functions. I've tried the following window.console.error = window.console.debug = wind

Solution 1:

You can use onerror it is designed to catch syntax errors.

window.onerror = function(message, source, lineno, colno, error) {
   alert(message);
}

Offical docs on MDN

Solution 2:

Here's a thread on this. Note the answer that shows how to "hijack" console.log() and send it wherever you want: Capturing javascript console.log?

Post a Comment for "Redirect Javascript Syntax Errors And Console.log To Somewhere Else"