Bläddra i källkod

Handle exceptions throw from module loader callback.

Simon Best 12 år sedan
förälder
incheckning
cd20140774
1 ändrade filer med 8 tillägg och 0 borttagningar
  1. 8 0
      v8js_methods.cc

+ 8 - 0
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);