Reputation: 7299
is there a way in which we can get the list of errors in the console using pure javascript or jquery or any other client side script?
console.error("params")
just creates error, but I am not able to access the list of errors in console with it
Upvotes: 1
Views: 1266
Reputation: 7425
There's no build in function in javascript to get a list of all errors but you may use window.onerror to append the error message to an array each time you get one.
var myErrors = [];
startTrackingErrors = true;
window.onerror = function (errorMessage, url, lineNumber) {
if (!startTrackingErrors) { return false; }
myErrors.push({
errorMessage : errorMessage,
url : url,
lineNumber : lineNumber
});
return true;
};
Here's a working demo (with error :P)
Upvotes: 2