Skip to content

Instantly share code, notes, and snippets.

@qrush
Created July 27, 2009 14:15
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save qrush/156368 to your computer and use it in GitHub Desktop.
post errors to hoptoad from actionscript
protected function sendToHoptoad (msg:String):void {
var yamlData:String = 'notice: \n'
+ ' api_key: YOUR_API_KEY\n'
+ ' error_message: "' + msg + '"\n'
+ ' backtrace: \n'
+ ' request: {}\n'
+ ' session: {}\n'
+ ' environment: \n'
+ ' RAILS_ENV: [YOUR_ENV_HERE]\n';
var req:URLRequest = new URLRequest("http://hoptoadapp.com/notices");
req.method = URLRequestMethod.POST;
req.data = yamlData;
req.contentType = "application/x-yaml";
var loader:URLLoader = new URLLoader(req);
loader.addEventListener(Event.COMPLETE, function (e:Event):void {
trace("Error tracker response: " + (URLLoader(e.target).data));
});
loader.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void {
trace("Failed to send error report. Failure message: " + e);
});
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, function (e:HTTPStatusEvent):void {
trace("HTTP Status: " + e);
});
loader.load(req);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment