0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-16 18:05:18 +00:00
phpv8/tests/exception_filter_002.phpt
2022-06-24 12:04:11 +02:00

33 lines
586 B
PHP

--TEST--
Test V8::setExceptionFilter() : Filter handling on exception in setModuleLoader
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$v8 = new V8Js();
$v8->setModuleLoader(function ($path) {
throw new Error('moep');
});
$v8->setExceptionFilter(function (Throwable $ex) {
echo "exception filter called.\n";
return $ex->getMessage();
});
$v8->executeString('
try {
require("file");
} catch(e) {
var_dump(e);
}
', null, V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS);
?>
===EOF===
--EXPECT--
exception filter called.
string(4) "moep"
===EOF===