Bug 16470 - Exception message contruction
Exception message contruction
Status: RESOLVED FIXED
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL
unspecified
PC All
: P2 normal
: ---
Assigned To: Cameron McCormack
public-webapps-bugzilla
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-21 19:22 UTC by Marcos Caceres
Modified: 2012-03-21 22:38 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos Caceres 2012-03-21 19:22:18 UTC
I might have screwed something up, but implementing the algorithm can result in message becoming "undefined", from this line: 

Test case:
var test = new FooError() 

Then: 
function(arg0) {
  //.... arg0 is undefined. 
  //If n > 0, then:
   if (arguments.length > 0) {

  //Let S be the result of calling ToString(arg0).
  var S = ECMAScript.ToString(arg0);
 
Maybe the spec should check that arg0 is not undefined? 

Question: can a default message be set somehow in through the IDL?
Comment 1 Marcos Caceres 2012-03-21 19:38:55 UTC
Also, I think the Exception JS binding section is confusing with regards to setting message (when no argument is missing). It should be a bit more clear that ECMAscript Error gives you message and type in the prototype.  

Generally, I've struggled a bit with the exception stuff... it is a bit all over the place. I have to bounce between many parts of the spec to find all the bits I need to put it together. It would be much easier if everything was brought together in one place with less critical bits missing from definitions. I guess once I'm done you will be able to see how I had to copy/paste parts of the spec into a kind of Frankenstein... I shouldn't have to do that when following algorithms (ECMAScript does this really nicely). 

code is here: 

https://github.com/marcoscaceres/ECMAScriptInJS/blob/master/WebIDL.js

Search for "ExceptionFactory".
Comment 2 Cameron McCormack 2012-03-21 22:38:25 UTC
Do you mean that passing undefined to built-in error constructors will result in no message being set, while for Web IDL error constructors it will set the message to "undefined"?  If so, you're right, we should follow what the built-in ones do.

Default messages cannot be set in the IDL.

I've added a clarifying note that setting the message property shadows the one from Error.prototype.

http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.489;r2=1.491;f=h