private void CrashLogger(object sender, UnhandledExceptionEventArgs e)
{
try
{
Exception ex = (Exception)e.ExceptionObject;
logger.Fatal("FATAL ERROR: {0}", ex.Message);
logger.Fatal("Here is the stacktrace:");
logger.Fatal(ex.StackTrace);
if (MessageBox.Show("Would you like to send anonymous debug information to Put.io?", "PutioFS crashed.", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.put.io/v1/mounter");
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = String.Format("method=log&api_key={0}&api_secret={1}&msg={2}", Settings.Default.APIKey, Settings.Default.Secret, ex.StackTrace);
byte[] data = encoding.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
}
catch (Exception)
{
MessageBox.Show("There was a problem sending the data.");
return;
}
MessageBox.Show("Debug information sent.");
}
}
finally
{
Application.Exit();
}
}