Skip to content

Instantly share code, notes, and snippets.

@bheylin
Created August 17, 2011 09:11
Show Gist options
  • Select an option

  • Save bheylin/1151146 to your computer and use it in GitHub Desktop.

Select an option

Save bheylin/1151146 to your computer and use it in GitHub Desktop.
Getting more debug info on what code created an async callback
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