Created
December 1, 2010 21:00
-
-
Save joelklabo/724215 to your computer and use it in GitHub Desktop.
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
// Returns a wrapped version of the method that returns | |
// the Error obj to JS-land instead of actually throwing | |
var genExtFunc:Function = function (func:Function):Function { | |
return function (...args):* { | |
try { | |
for (var arg:* in args){ | |
// Terrible hack working around half baked | |
// ExternalInterface support provided by | |
// Safari on Windows | |
// takes json strings and turns them into objects | |
if (args[arg] is String){ | |
var o : Object = JSON.decode(args[arg]); | |
args[arg] = o; | |
} | |
} | |
return func.apply(null, args); | |
} | |
catch (e:Error) { | |
if (e.errorID == 1009){ | |
e.message = "There was a problem with your parameters, " + JSON.encode(args); | |
} | |
return e; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment