Can I detect whether Chrome has 'pause on errors' or devtools open from website javascript? (For error handling)

StackOverflow https://stackoverflow.com/questions/19666559

I have a generic error handling function that traps window.onerror and either displays the error on screen as an alert if the code is in dev/staging mode, or logs the error message via ajax post in production mode. This is good, and I especially like the way it pops up an alert for testers or devs who don't happen to have devtools open while coding or testing.

However, if someone does have devtools open, I don't want to catch the exception - I want to use the nice chrome devtools to point out the error.

Note this is from the web page javascript, not from a chrome extension (ideally). In other browsers I am happy to always show the alert (ie if not chrome then always alert).

So, can I either:

a) detect whether 'pause on errors' is active?

b) detect whether devtools is open?

c) maybe I could make a chrome extension to check if devtools is open?

Anyone tried something like this?

有帮助吗?

解决方案

I don't think you can. If you could, this might be considered a security vulnerability.

But, do you realize that you can set Developer Tools to break on all exceptions, effectively bypassing your own page's error handling code? Go to the sources tab and click the pause button until it is blue.

Catch all errors

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top