flash - ActionScript Compiler UncaughtErrorEvent -


after using asc2 compile air application, found error stack trace missing while catching uncaughterrorevent.

here example code:

var root:sprite = this; root.loaderinfo.uncaughterrorevents.addeventlistener(uncaughterrorevent.uncaught_error,errorhandle); throw new error("test");  protected function errorhandle(event:uncaughterrorevent):void         {             var message:string;              if (event.error error) {                  message = error(event.error).message;                  message+="\n"+error(event.error).getstacktrace();             } else if (event.error errorevent) {                  message = errorevent(event.error).text;             } else {                  message = event.error.tostring();              }          } 

while using asc1, can see full stack trace in error handle. using asc2, empty stack trace.

anyone have same problem?

how uncaughterrorevent stack trace?

don't cast event.error error, in:

error(event.error).getstacktrace() 

getting error's stack trace returns call stack error @ time of error's construction string. note line number of stack trace line of cast.

instead, call getstacktrace() event.error, in:

event.error.getstacktrace() 

there's nothing significant on stack per example.

adding recursion helps demonstrate issue:

package {     import flash.display.sprite;     import flash.events.uncaughterrorevent;      public class exceptiontest extends sprite     {         public function exceptiontest()         {             super();              loaderinfo.uncaughterrorevents.addeventlistener(uncaughterrorevent.uncaught_error, uncaughterrorhandler);             recursion();         }          protected function recursion(depth:uint=0):void         {             if (depth == 5)                 throw new error("test");             else                 recursion(++depth);         }          protected function uncaughterrorhandler(event:uncaughterrorevent):void         {             trace(event.error.getstacktrace());         }     } } 

...would produce:

error: test     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:19]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:13] [swf] users:jsturges:dev:flash-workspace:x:bin-debug:exceptiontest.swf - 1,745 bytes after decompression error: test     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:19]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:13] 

if uncaughterrorhandler() changed example casting error, in:

protected function uncaughterrorhandler(event:uncaughterrorevent):void {     trace(error(event.error).getstacktrace()); } 

the debugger catches exception, getstacktrace line of cast:

error: test     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:19]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest/recursion()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:21]     @ exceptiontest()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:13] [swf] users:jsturges:dev:flash-workspace:x:bin-debug:exceptiontest.swf - 1,519 bytes after decompression error: error: test     @ exceptiontest/uncaughterrorhandler()[/users/jsturges/dev/flash-workspace/x/src/exceptiontest.as:26] 

there may nuances marshaling as1 , as2 as3 supports uncaughterrorevent starting @ flash player 10.1.

beyond that, assure appropriate debug player per actionscript version. in non-debugger version of runtime error.getstacktrace() method returns null.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -