Browse Source

Update CallStack.hx (#9947)

Aleksandr Kuzmenko 4 years ago
parent
commit
236ee3de4e
2 changed files with 8 additions and 3 deletions
  1. 4 0
      extra/CHANGES.txt
  2. 4 3
      std/haxe/CallStack.hx

+ 4 - 0
extra/CHANGES.txt

@@ -1,5 +1,9 @@
 2020-XX-XX 4.1.5:
 
+	General improvements:
+
+	all : added an argument to `haxe.CallStack.exceptionStack` to return full stack up to the topmost call (#9947)
+
 	Bugfixes:
 
 	jvm : fixed equality checks for `Null<Float>` and `Null<Int>` (#9897)

+ 4 - 3
std/haxe/CallStack.hx

@@ -56,12 +56,13 @@ abstract CallStack(Array<StackItem>) from Array<StackItem> {
 		Return the exception stack : this is the stack elements between
 		the place the last exception was thrown and the place it was
 		caught, or an empty array if not available.
+		Set `fullStack` parameter to true in order to return the full exception stack.
 
 		May not work if catch type was a derivative from `haxe.Exception`.
 	**/
-	public static function exceptionStack():Array<StackItem> {
+	public static function exceptionStack( fullStack = false ):Array<StackItem> {
 		var eStack:CallStack = NativeStackTrace.toHaxe(NativeStackTrace.exceptionStack());
-		return eStack.subtract(callStack()).asArray();
+		return (fullStack ? eStack : eStack.subtract(callStack())).asArray();
 	}
 
 	/**
@@ -181,4 +182,4 @@ abstract CallStack(Array<StackItem>) from Array<StackItem> {
 				b.add(n);
 		}
 	}
-}
+}