You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+16
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,15 @@ class V8Js
104
104
public function setModuleNormaliser(callable $normaliser)
105
105
{}
106
106
107
+
/**
108
+
* Provate a function or method to be used to convert/proxy PHP exceptions to JS.
109
+
* This can be any valid PHP callable.
110
+
* The converter function will receive the PHP Exception instance that has not been caught and
111
+
* is due to be forwarded to JS. Pass NULL as $filter to uninstall an existing filter.
112
+
*/
113
+
public function setExceptionFilter(callable $filter)
114
+
{}
115
+
107
116
/**
108
117
* Compiles and executes script in object's context with optional identifier string.
109
118
* A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException.
@@ -369,3 +378,10 @@ objects obeying the above rules and re-thrown in JavaScript context. If they
369
378
are not caught by JavaScript code the execution stops and a
370
379
`V8JsScriptException` is thrown, which has the original PHP exception accessible
371
380
via `getPrevious` method.
381
+
382
+
Consider that the JS code has access to methods like `getTrace` on the exception
383
+
object. This might be unwanted behaviour, if you execute untrusted code.
384
+
Using `setExceptionFilter` method a callable can be provided, that may convert
385
+
the PHP exception to some other value that is safe to expose. The filter may
386
+
also decide not to propagate the exception to JS at all by either re-throwing
387
+
the passed exception or throwing another exception.
0 commit comments