0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-09 15:18:41 +00:00
phpv8/tests/exception_proxy_004.phpt

38 lines
926 B
Plaintext
Raw Normal View History

--TEST--
Test V8::setExceptionProxyFactory() : Proxy handling on exception in factory
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
class myv8 extends V8Js
{
public function throwException(string $message) {
throw new Exception($message);
}
}
$v8 = new myv8();
$v8->setExceptionProxyFactory(function (Throwable $ex) {
throw new Exception('moep');
});
try {
$v8->executeString('
try {
PHP.throwException("Oops");
print("done\\n");
}
catch (e) {
print("caught\\n");
var_dump(e);
}
', null, V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS);
} catch (Exception $ex) {
echo "caught in php: " . $ex->getMessage() . PHP_EOL;
}
?>
===EOF===
--EXPECT--
caught in php: moep
===EOF===