Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

External exception lost #76

Closed
pinepain opened this issue Oct 22, 2017 · 0 comments
Closed

External exception lost #76

pinepain opened this issue Oct 22, 2017 · 0 comments
Assignees
Milestone

Comments

@pinepain
Copy link
Member

When V8 exception thrown with an V8 object that has no PHP reference stored, correspondent external exception did not pop up in a final result:

<?php
/** @var \Phpv8Testsuite $helper */
$helper = require '.testsuite.php';

require '.v8-helpers.php';
$v8_helper = new PhpV8Helpers($helper);


$isolate = new \V8\Isolate();
$context = new \V8\Context($isolate);
$v8_helper->injectConsoleLog($context);

$global = $context->globalObject();

$func_tpl = new \V8\FunctionObject($context, function (\V8\FunctionCallbackInfo $info) {
    $isolate = $info->getIsolate();
    $context = $info->getContext();
    $info->getIsolate()->throwException($info->getContext(), \V8\ExceptionManager::createError($context, new \V8\StringValue($isolate, 'test')), new RuntimeException('test'));
});

$global->set($context, new \V8\StringValue($isolate, 'e'), $func_tpl);


try {
    $v8_helper->CompileRun($context, 'e()');
} catch (\V8\Exceptions\TryCatchException $e) {
    $helper->exception_export($e);

    $helper->assert('No external exception present', $e->getTryCatch()->getExternalException(), null);
}

$v8_helper->CompileRun($context, 'try {e()} catch(e) {}');

outputs

V8\Exceptions\TryCatchException: Error: test
No external exception present: ok

It looks like we might need to store reference to exception objects thrown on some isolate-specific stack.

@pinepain pinepain added this to the 0.2.1 milestone Oct 22, 2017
@pinepain pinepain self-assigned this Oct 22, 2017
pinepain added a commit that referenced this issue Oct 23, 2017
Store exception object when external exception given, closes #76
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant