1

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

1 Answer 1

2

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)

Sign up to request clarification or add additional context in comments.

6 Comments

Glad that it helped, Cheers :)
What is startTrackingErrors?
Just a flag to make sure we track errors only when we want to. Keep it true if you want to track errors by default. Here's a working plunkr
In IE, it is not throwing an error in the console, but it displays "The content cannot be displayed in an iframe" :( not sure how to solve this for IE as its not throwing error in console too
check out this plunkr in IE and chrome plnkr.co/edit/jJKFfZZX8GHQA0jJpj4r?p=preview
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.