Explorar el Código

[php] proper implementation of `Lib.rethrow()`

Aleksandr Kuzmenko hace 6 años
padre
commit
0fd449832b
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  1. 7 2
      std/php/Lib.hx

+ 7 - 2
std/php/Lib.hx

@@ -129,9 +129,14 @@ class Lib {
 	}
 
 	/**
-		For neko compatibility only.
+		Rethrows an exception.
+		If `e` is not a value caught in `try...catch` or if called outside of `catch` block, then `e` is thrown as
+		a new exception.
 	**/
-	public static inline function rethrow( e : Dynamic ) {
+	extern public static inline function rethrow( e : Dynamic ) {
+		if(Syntax.code("isset($__hx__caught_e, $__hx__real_e)") && e == Syntax.code("$__hx__real_e")) {
+			Syntax.code("throw $__hx__caught_e");
+		}
 		throw e;
 	}