I am writing an unhandled Promise rejection handler. Within the handler, I want to be able to tell if the rejection is caused by the client blocking a fetch request, via adblock or etc.
With adblock enabled, if you try to fetch "https://ad.doubleclick.net"
, it shows net::ERR_BLOCKED_BY_CLIENT
in the console:
But when that bubbles out to window.onunhandledrejection
, there's no way to tell that that's why the Promise was rejected; the error message says "TypeError: failed to fetch", but that's pretty vague.
Is there a way to detect that the error is due to adblock?