Joy Online Manual

Exception Handling

When you call an Objective-C method or C function from JavaScript and an Objective-C exception occurs, Joy will automatically reraise it as a JavaScript exception. You can then handle it from JavaScript using either try...catch or the Objective-C alternative NS_DURING...NS_HANDLER. If your JavaScript code doesn't catch the exception it will propagate up the calling stack until an Objective-C method or C function is reached, where it will be converted back to an Objective-C exception and reraised.

If an Objective-C exception was originally caused by a JavaScript error (Joy can tell that from the exception's name) and you are using the JavaScript try...catch statement, the original JavaScript error will automatically be extracted from the exception's userInfo and re-reported.

If you are using NS_DURING...NS_HANDLER (whether in JavaScript or Objective-C), JavaScript errors are reported as NSExceptions with a name of ItkObjCJSErrorException, a reason equal to the error message (if there are multiple errors, they are joined together with newlines), and a userInfo that is an NSArray of NSDictionaries, one for each error, with members corresponding to the fields of the JSErrorReport structure from jsapi.h.

Index