diff --git a/README.md b/README.md index 64182da..bca66e5 100644 --- a/README.md +++ b/README.md @@ -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.