Created
August 17, 2011 09:11
-
-
Save bheylin/1151146 to your computer and use it in GitHub Desktop.
Getting more debug info on what code created an async callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package | |
| { | |
| import flash.events.TimerEvent; | |
| import flash.utils.Timer; | |
| public class TestClass | |
| { | |
| public function TestClass(userCallback:Function) | |
| { | |
| var errorInConsumerScope:Error = new Error() | |
| var timer:Timer = new Timer(1000, 1) | |
| timer.addEventListener(TimerEvent.TIMER, internalCallback) | |
| timer.start() | |
| function internalCallback(e:TimerEvent):void | |
| { | |
| try | |
| { | |
| var nullProperty:String | |
| nullProperty.length | |
| userCallback() | |
| } | |
| catch (e:Error) | |
| { | |
| errorInConsumerScope.message = e.message | |
| throw errorInConsumerScope | |
| } | |
| } | |
| } | |
| } | |
| } | |
| package | |
| { | |
| import flash.display.Sprite; | |
| public class Main extends Sprite | |
| { | |
| public function Main() | |
| { | |
| new TestClass(function ():void { | |
| trace('call me back when your done') | |
| }) | |
| } | |
| } | |
| } | |
| /* | |
| Error: Error #1009: Cannot access a property or method of a null object reference. | |
| at TestClass()[/[path-to-source-file]/TestClass.as:10] | |
| at Main()[/[path-to-source-file]/Main.as:9] | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment