I've encountered an issue that drives me completely nuts.
My chrome extension doesn't report any errors to Developer Tools console. BUT: it still writes logs, works generally well, and the non-extension scripts on the page still report their errors.
I've seen some words that extension's errors can be displayed in popup.html's DevTools window, but my extension doesn't (and can't by design, it is made for parsing other pages) use that popup.html at all.
The worst thing is that even syntax errors (!) of extension are not displayed. I'd be infinitely and eternally grateful if you could give me the solution for this problem, for it is a huge pain in the ass debugging an extension without syntax errors notifications : (
UPD:
As it appears, the problem is that only on one page I can't see errors: on the other pages where my script runs I can see console.errors().
Rob W, sorry, but that doesn't answer my question. I can use console.log(), but I can't see the output of console.error(), both from actual errors in script and my own calls of console.error(). My script doesn't use the background scripts, only certain scripts for certain pages, as in the manifest.json below:
{
"manifest_version": 2,
"permissions": ["tabs", "http://*/*", "https://*/*", "file:///*/*"],
...
"content_scripts": [{
// I can see my errors here...
"matches": ["http://www.site.ru/*type=cheats*"],
"js": ["cheats.js"]
},{
// and here...
"matches": ["http://www.site.ru/bitrix/admin/iblock_element_edit.php*type=games*"],
"js": ["idb.js","data.js","framework.js","script.js","wikipic.js"],
"css":["styles.css"],
"all_frames": true
},{
"matches": ["http://www.site.ru/bitrix/admin/iblock_element_search.php*"],
"js": ["search.js"]
},{
// >>>> But not here! <<<<
"matches": ["http://www.site.ru/cheats/*"],
"js": ["keys.js", "adhocparse.js", "resumeer.js", "ground.js"],
"css": ["resumeer.css"]
}]
}
UPD 2: I tried this code:
console.log(console, console.log, console.error);
console.error("Error one");
throw new Error("Error two");
I've got this output:
Console function log() { [native code] } function error() { [native code] }
Error one
So: console.error works, but all thrown errors (such as syntax errors) are somehow catched globally. It is strange, because:
- I don't have any catches in my extension;
- Page itself still generates a lot of errors (but they occur before calling my extension code), and a lot of GET errors (unable to get a file, even after calling my extension code, but they seem to be uncatchable, I guess)
So what can catch errors globally?
It appears that this is not a Chrome extension issue, added tag javascript.