简体   繁体   中英

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

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.

捕获所有错误

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM