var f:Function = function():void { trace('Hello'); throw new Error("My custom Error"); } try { f(); } catch(e:Error) { trace('Catched error: '+e); }