jerryscript
jerryscript copied to clipboard
Jerry API: propagating unhandled exception.
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, 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 Yes, of course. It would be good.
@ILyoan, thank you.
Pull request #188 performs the update.
Merged (#188).