[webkit-dev] Improving DOM Exception console messages.
mkwst at chromium.org
Wed Sep 26 08:12:25 PDT 2012
TL;DR: I'd like to improve the console messages displayed for DOM
exceptions. I'm hoping that no one thinks this is a miserable,
At the moment, the following code generates an exception with a
message reading "SECURITY_ERR: DOM Exception 18".
<meta http-equiv="X-WebKit-CSP" content="connect-src 'none'">
var xhr = new XMLHttpRequest();
var url = 'https://api.twitter.com/1/trends/daily.json?exclude=hashtags';
xhr.open('GET', url, true);
In this case, the exception is generated because Content Security
Policy blocks the XMLHttpRequest, but it's tough to tell, because the
exact same error crops up for 31 different exception cases. It
might be CSP, it might be a disallowed HTTP method, who knows. Because
of the variety, searching for the exception message is unhelpful. In
this case, I end up on StackOverflow, reading about cookies and
jQuery, which is unlikely to be of service.
This isn't a great experience, and while SECURITY_ERR is particularly
widespread, the scenario is similar for the other DOM exceptions
WebKit throws. Each ends up in ExceptionBase, where a message is
assembled from the exception type and code, and the developer is left
more than a little underinformed.
I'd like to add the ability to pass some sort of contextual message
along with the error code. This would involve some work on JSC and V8
bindings, as well as a whole lot of single-line changes to the various
bits of the DOM where these error codes are generated.
In this case, a useful message might be: "SECURITY_ERR: DOM Exception
18. XMLHttpRequest connections to
'http://localhost:8000/xmlhttprequest/resources/get.txt' are blocked
due to this page's Content Security Policy." This would have the
positive impact of giving developers something useful to work with. It
would also have the impact of changing the exception text, which is
why I'm writing this email. :)
Before I get too far along in experimental implementations, are there
fundamental objections to changing the exception text to include some
More information about the webkit-dev