问题描述:

I am following the book "Professional Haxe and Neko" written by Franco Ponticelli and Lee McColl-Sylvester.

Chapter 7-When Things Go Wrong is about errors and exceptions

When I follow the code outlined on pg.192 (which I have minimized here) I have

class CallStack{

public static function main():Void{

var i:Int = 0;

i = multiply(i, 6);

}

public static function multiply(a,b){

return a * traceStack(b);

}

public static function traceStack(a){

var cs = haxe.CallStack.callStack();

trace(haxe.CallStack.toString(cs));

return a;

}

}

When I compile this code it returns an empty callStack.

According to the Haxe API the callStack() function

"Returns the call stack elements, or an empty array if not available."

So my questions are these,

Why wouldn't the stack elements be available?

What else would cause the callStack function to return an empty Array?

Is there a better method to use to retrieve this information?

网友答案:

Stack traces are likely not available unless you are running in debug mode.

相关阅读:
Top