1

I'm trying to create a Chrome extension that will log all the javascript errors that show up in the Javascript console and then send that to me.

I've been trying the chrome.debugger.onEvent.addListener and the window.onerror and nothing seems to be running. Can someone point me in the right direction?

These are not syntax errors by the way. They are network errors. The page might return an error and I want to log that.

9
  • You mean the log in background or content script? Commented May 23, 2016 at 21:48
  • Can you show your code that is not working? Commented May 23, 2016 at 21:49
  • I want to log the errors on occur page (Such as a failed ajax call. But I am using an extension to log this.) Commented May 23, 2016 at 21:50
  • I am using window.onerror = function(msg, url, line) and tried injecting it onto the page with the extension: "run_at" : "document_start" with the JS. But it never goes into my function Commented May 23, 2016 at 21:51
  • 1
    OK, so the console data in content script. As the answer in this post, there is no direct way to get console data: stackoverflow.com/questions/19846078/… Commented May 23, 2016 at 21:52

1 Answer 1

1

I found Evaluating network performance in one of my researches and it might help you.

It mentioned about Network panel that automatically records all network activity while DevTools is open. And also uses the Resource Timing API, a Javascript that provides detailed networking timing data for each loaded resource and is available to any web page, not just DevTools.

Try this: open the JavaScript console on the current page, enter the following at the prompt, and hit Return:

window.performance.getEntries()[0]

This evaluates the first element in the array of resource timing objects and displays its properties in the console. However, please note that by default, the current network record log is discarded when you navigate to another page, or reload the current page.

More information on how to preserve the recording log in these scenarios can be found in the documentation. And, in addition to that, this SO post - How to use chrome's network debugger with redirects can also be quite useful.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.