0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-16 19:15:17 +00:00

Mention setExceptionProxyFactory in README

This commit is contained in:
Stefan Siegl 2022-05-31 16:16:30 +02:00
parent ca38f724c8
commit abb8b6df14

View File

@ -104,6 +104,15 @@ class V8Js
public function setModuleNormaliser(callable $normaliser)
{}
/**
* Provate a function or method to be used to convert/proxy PHP exceptions to JS.
* This can be any valid PHP callable.
* The factory function will receive the PHP Exception instance that has not been caught and is
* due to be forwarded to JS.
*/
public function setExceptionProxyFactory(callable $factory)
{}
/**
* Compiles and executes script in object's context with optional identifier string.
* A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException.
@ -401,3 +410,8 @@ objects obeying the above rules and re-thrown in JavaScript context. If they
are not caught by JavaScript code the execution stops and a
`V8JsScriptException` is thrown, which has the original PHP exception accessible
via `getPrevious` method.
Consider that the JS code has access to methods like `getTrace` on the exception
object. This might be unwanted behaviour, if you execute untrusted code.
Using `setExceptionProxyFactory` method a callable can be provided, that converts
the PHP exception to not expose unwanted information.