exception_filter_004.phpt 917 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Test V8::setExceptionFilter() : Filter handling on exception in converter
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. class myv8 extends V8Js
  8. {
  9. public function throwException(string $message) {
  10. throw new Exception($message);
  11. }
  12. }
  13. $v8 = new myv8();
  14. $v8->setExceptionFilter(function (Throwable $ex) {
  15. throw new Exception('moep');
  16. });
  17. try {
  18. $v8->executeString('
  19. try {
  20. PHP.throwException("Oops");
  21. print("done\\n");
  22. }
  23. catch (e) {
  24. print("caught\\n");
  25. var_dump(e);
  26. }
  27. ', null, V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS);
  28. } catch (Exception $ex) {
  29. echo "caught in php: " . $ex->getMessage() . PHP_EOL;
  30. }
  31. ?>
  32. ===EOF===
  33. --EXPECT--
  34. caught in php: moep
  35. ===EOF===