Browse Source

[java] added cause to add correct stack trace

Caue Waneck 13 years ago
parent
commit
bd15be83d0
1 changed files with 10 additions and 4 deletions
  1. 10 4
      std/java/_std/haxe/lang/Exceptions.hx

+ 10 - 4
std/java/_std/haxe/lang/Exceptions.hx

@@ -10,9 +10,9 @@ import java.lang.Throwable;
 {
 	private var obj:Dynamic;
 	
-	public function new(obj:Dynamic)
+	public function new(obj:Dynamic, msg:String, cause:Throwable)
 	{
-		super(null, null);
+		super(msg, cause);
 		
 		if (Std.is(obj, HaxeException))
 		{
@@ -35,8 +35,14 @@ import java.lang.Throwable;
 	
 	public static function wrap(obj:Dynamic):RuntimeException
 	{
-		if (Std.is(obj, RuntimeException)) return obj;
+		if (Std.is(obj, RuntimeException)) 
+			return obj;
 		
-		return new HaxeException(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);
 	}
 }