0
0
mirror of https://github.com/phpv8/v8js.git synced 2025-01-03 15:41:55 +00:00

Throw V8JsException if v8 context cannot be created

We used to reset This to NULL, which never reallt was supposed to work
and PHP doc explicitly tell to not touch EX(This)
This commit is contained in:
Stefan Siegl 2015-10-03 00:01:12 +02:00
parent 8a3124ee2a
commit b8726409f4
2 changed files with 10 additions and 6 deletions

View File

@ -37,6 +37,8 @@ Exception thrown during bootstrapping
Extension or internal compilation error%sin handlebars at line 1.
Error installing extension 'handlebars'.
Warning: V8Js::__construct(): Failed to create V8 context. Check that registered extensions do not have errors. in %s on line %d
NULL
===EOF===
Fatal error: Uncaught V8JsException: Failed to create V8 context. Check that registered extensions do not have errors. in %s%eextensions_error.php:7
Stack trace:
#0 %s%eextensions_error.php(7): V8Js->__construct()
#1 {main}
thrown in %s%eextensions_error.php on line 7

View File

@ -347,7 +347,8 @@ static PHP_METHOD(V8Js, __construct)
{
exts_count = zend_hash_num_elements(Z_ARRVAL_P(exts_arr));
if (v8js_create_ext_strarr(&exts, exts_count, Z_ARRVAL_P(exts_arr)) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid extensions array passed");
zend_throw_exception(php_ce_v8js_exception,
"Invalid extensions array passed", 0);
return;
}
}
@ -387,8 +388,9 @@ static PHP_METHOD(V8Js, __construct)
/* If extensions have errors, context will be empty. (NOTE: This is V8 stuff, they expect the passed sources to compile :) */
if (context.IsEmpty()) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to create V8 context. Check that registered extensions do not have errors.");
ZVAL_NULL(getThis());
zend_throw_exception(php_ce_v8js_exception,
"Failed to create V8 context. "
"Check that registered extensions do not have errors.", 0);
return;
}