/// <summary> /// args: [url, data] /// Returns 1 if reporting failed, or the response from server is not "OK". /// </summary> static void Main(string[] args) { try { var url = args[0]; var data = args[1]; var req = GetPostRequest(url, new Dictionary <string, string>() { ["data"] = data }); var str = req.GetResponse().GetResponseString(); if (str != "OK") { throw new Exception("Response from server: " + str); } } catch (Exception e) { Console.WriteLine(e.ToString()); ExceptionHelpers.IgnoreException( () => File.WriteAllText("./ErrorReporterLog.txt", e.ToString())); Environment.Exit(1); } Environment.Exit(0); }
public void Load(XDocument doc) { var r = doc.Root; var c = control; var a = control.airportInfoControl; var w = control.weatherInfoControl; // The order is important. E.g. "pressUnit" has to be // loaded before "pressure", due to events handlers attached // to pressure.TextChanged. Action[] actions = { () => a.airportTxtBox.Text = r.GetString(airportIcao), () => a.rwyComboBox.Text = r.GetString(rwy), () => a.lengthUnitComboBox.Text = r.GetString(lengthUnit), () => w.windDirTxtBox.Text = r.GetString(windDir), () => w.windSpdTxtBox.Text = r.GetString(windSpeed), () => w.tempUnitComboBox.Text = r.GetString(tempUnit), () => w.oatTxtBox.Text = r.GetString(oat), () => w.pressUnitComboBox.Text = r.GetString(pressUnit), () => w.pressTxtBox.Text = r.GetString(pressure), () => w.surfCondComboBox.Text = r.GetString(surfCond), () => c.acListComboBox.Text = r.GetString(aircraft), () => c.wtUnitComboBox.Text = r.GetString(wtUnit), () => c.weightTxtBox.Text = r.GetString(toWt), () => c.flapsComboBox.Text = r.GetString(flaps), () => c.thrustRatingComboBox.Text = r.GetString(thrustRating), () => c.antiIceComboBox.Text = r.GetString(antiIce), () => c.packsComboBox.Text = r.GetString(packs) }; foreach (var action in actions) { ExceptionHelpers.IgnoreException(action); } }
public void IgnoreExceptionTest() { Action a = () => { throw new ArgumentException(); }; ExceptionHelpers.IgnoreException(a); }
private static void TryDelete(string path) { ExceptionHelpers.IgnoreException(() => File.Delete(path)); }