I want to be able to throw an error to be traced to the trace output window and to my flashlog.txt file but continue code execution after the error. Is this possible in Actionscript 3? A try catch will not work either because I need the error to be logged with its call stack.
Share
If by trace output window you mean the window that pops up when an Error is thrown (as opposed to the trace window in the Flash IDE, Flash Builder, etc), there’s a bit hackish workaround. Basically, you have to delay the call to
throwso it runs in its own stack call.Something like this should do it:
Of course you have to pass the error to this function, instead of throwing it directly.
If you just want to get the stack trace from an existent error, though, catch it and get the stack trace as The_asMan showed.
Also, if you just want to have the stack trace at some point (but don’t want to actually throw an error), just create the error and call
getStackTrace, without throwing. In this case, you don’t really need a catch.