jerryscript icon indicating copy to clipboard operation
jerryscript copied to clipboard

Jerry API: propagating unhandled exception.

Open ILyoan opened this issue 11 years ago • 4 comments

Was there an unhandled exception rasied, jerry_api_invoke_function() returns false with undefined for retval_p. But user of this API might want to know what error was occurred during execution (actually IoT.js do want to know). What about exposing the error with retval_p parameter in case of exception?

ILyoan avatar Jun 15 '15 05:06 ILyoan

@ILyoan, we could update the API, as the following:

/**
 * Call function specified by a function object
 *
 * Note:
 *      returned value should be freed with jerry_api_release_value
 *      just when the value becomes unnecessary.
 *
 * @return true, if call was performed successfully, i.e.:
 *                - specified object is a function object (see also jerry_api_is_function);
 *                - no unhandled exceptions were thrown in connection with the call;
 *         false - otherwise, 'retval_p' contains thrown exception:
 *                if called object is not function object - a TypeError instance;
 *                else - exception, thrown during the function call.
 */

and

/**
 * Construct object invoking specified function object as a constructor
 *
 * Note:
 *      returned value should be freed with jerry_api_release_value
 *      just when the value becomes unnecessary.
 *
 * @return true, if construction was performed successfully, i.e.:
 *                - specified object is a constructor function object (see also jerry_api_is_constructor);
 *                - no unhandled exceptions were thrown in connection with the invocation;
 *         false - otherwise, 'retval_p' contains thrown exception:
 *                if  specified object is not a constructor function object - a TypeError instance;
 *                else - exception, thrown during the invocation.
 */

Would the updated versions be convenient to use in IoT.js?

ruben-ayrapetyan avatar Jun 15 '15 10:06 ruben-ayrapetyan

@ruben-ayrapetyan Yes, of course. It would be good.

ILyoan avatar Jun 15 '15 11:06 ILyoan

@ILyoan, thank you.

Pull request #188 performs the update.

ruben-ayrapetyan avatar Jun 15 '15 12:06 ruben-ayrapetyan

Merged (#188).

ruben-ayrapetyan avatar Jun 17 '15 16:06 ruben-ayrapetyan