[webkit-dev] JSC: Callback functions returning exception, what should be the JSValueRef return?

Darin Adler darin at apple.com
Tue Aug 11 11:40:49 PDT 2009


I feel bad that we didn't move this to webkit-help. This list is  
supposed to be for development of WebKit. While that list is for help  
using WebKit.

On Aug 11, 2009, at 11:34 AM, Brian Barnes wrote:

> when I need to throw an exception, right now I just create a string  
> JSValueRef with my exception's description. I assume when it returns  
> to the JSC core it's properly wrapped into an exception object,  
> correct?

Since the JavaScript language lets you throw any value as an  
exception, so does the JavaScriptCore API.

If you want an object for your exception, one that will end up with  
line number properties and the like, then you’ll need to create one.  
The API won’t make it for you.

The objects that are thrown by the engine itself are Error objects,  
but there's no real need for you to use that prototype. You could  
throw almost any kind of object. I suggest just creating one with  
JSObjectMake and NULL for the class. And you could attach a message  
with the property name "message" to be a bit like an Error object.

     -- Darin



More information about the webkit-dev mailing list