|
@@ -24,6 +24,17 @@ import java.lang.Throwable;
|
|
|
import java.lang.RuntimeException;
|
|
|
import java.lang.Exception;
|
|
|
|
|
|
+@:allow(haxe.CallStack)
|
|
|
+@:allow(java.lang.RuntimeException)
|
|
|
+@:native("haxe.lang.Exceptions")
|
|
|
+class Exceptions {
|
|
|
+ private static var exception = new java.lang.ThreadLocal<java.lang.RuntimeException>();
|
|
|
+
|
|
|
+ private static function currentException() {
|
|
|
+ return exception.get();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
@:nativeGen @:keep @:native("haxe.lang.HaxeException") private class HaxeException extends RuntimeException
|
|
|
{
|
|
|
private var obj:Dynamic;
|
|
@@ -53,14 +64,16 @@ import java.lang.Exception;
|
|
|
|
|
|
public static function wrap(obj:Dynamic):RuntimeException
|
|
|
{
|
|
|
- if (Std.is(obj, RuntimeException))
|
|
|
- return obj;
|
|
|
-
|
|
|
- if (Std.is(obj, String))
|
|
|
- return new HaxeException(obj, obj, null);
|
|
|
- else if (Std.is(obj, Throwable))
|
|
|
- return new HaxeException(obj, null, obj);
|
|
|
-
|
|
|
- return new HaxeException(obj, null, null);
|
|
|
+ var ret:RuntimeException = null;
|
|
|
+ if (Std.is(obj, RuntimeException))
|
|
|
+ ret = obj;
|
|
|
+ else if (Std.is(obj, String))
|
|
|
+ ret = new HaxeException(obj, obj, null);
|
|
|
+ else if (Std.is(obj, Throwable))
|
|
|
+ ret = new HaxeException(obj, null, obj);
|
|
|
+ else
|
|
|
+ ret = new HaxeException(obj, null, null);
|
|
|
+ Exceptions.exception.set( ret );
|
|
|
+ return ret;
|
|
|
}
|
|
|
}
|