diff --git a/v8js_methods.cc b/v8js_methods.cc index b4754af..93568fc 100644 --- a/v8js_methods.cc +++ b/v8js_methods.cc @@ -25,6 +25,7 @@ extern "C" { #include "php.h" +#include "zend_exceptions.h" } #include "php_v8js_macros.h" @@ -285,6 +286,13 @@ V8JS_METHOD(require) return v8::ThrowException(v8::String::New("Module loader callback failed")); } + // Check if an exception was thrown + if (EG(exception)) { + // Clear the PHP exception and throw it in V8 instead + zend_clear_exception(TSRMLS_CC); + return v8::ThrowException(v8::String::New("Module loader callback exception 456")); + } + // Convert the return value to string if (Z_TYPE(module_code) != IS_STRING) { convert_to_string(&module_code);