Subj : Re: How do I raise an exception? To : Thomas Sondergaard From : Brendan Eich Date : Wed Aug 03 2005 10:39 am Thomas Sondergaard wrote: > Brendan Eich wrote: > >> If you want to make an instance of Error and throw it, you'll have to >> get the value of the "Error" property of a properly initialized or >> otherwise (lazy standard class resolution) configured global object, >> and save it with a rooted pointer or jsval. >> >> Then you can call this Error constructor function object reference >> with the JS_CallFunctionValue API, to create the exception object you >> wish to throw, passing appropriate arguments. If that all works, set >> the new exception object reference as the pending exception and return >> false. >> >> /be > > > Does this look reasonable? It's not what I suggested, and it's quite a bit more costly (running the compiler to make a function that's called and then GC'd, all to create and throw an Error instance). What I suggested should be a few lines of JS API calling, if you ignore error checks. /be .