Hi,  
I'm currently trying to implement a spec using ECMAScript. Unfortunately, I 
have a bunch of DOMExceptions that can't be thrown cleanly because there is no 
way to instantiate a DOMException through ECMAScript (new DOMException(...) 
returns a "TypeError: Illegal constructor" in browsers).   

An example of a conformance requirement I'm trying to implement:  

"When instructed to throw a security exception, the user agent throws a 
"SecurityError" DOMException, with its message set to "Access to 'scheme x://' 
is not allowed.", where x is replaced by the name of the disallowed scheme."

I've noticed that other developers have come up against the same issue, and 
have found some nasty workarounds (coercing an exception from some other code, 
and then throwing that instead [1]).  

So… given that one can fake create a DOMException, and unless there is a valid 
reason not to allow this that I don't know of…. It would be nice if 
DOMException just defined a public constructor. This would allow clean 
prototyping of various APIs in ECMAScript (and give us poor saps who don't know 
C a chance to implement some Web APIs :) ).  

[1] 
http://stackoverflow.com/questions/5136727/manually-artificially-throwing-a-domexception-with-javascript
  



Reply via email to