/// <summary> /// Sends the given report to the web service of 3P /// </summary> private static void SendBugReport(ExceptionInfo bugReport) { var wb = new WebServiceJson(WebServiceJson.WebRequestMethod.Post, Config.BugsPostWebWervice); wb.Serialize(bugReport); // save the request in a file var fileName = Path.Combine(Config.FolderLog, "unreported_" + DateTime.Now.ToString("yy.MM.dd_HH-mm-ss_") + _nbErrors++ + ".json"); Utils.FileWriteAllText(fileName, wb.JsonRequest.ToString()); wb.OnRequestEnded += webServ => { // request ok -> delete the json if (webServ.StatusCodeResponse == HttpStatusCode.OK) Utils.DeleteFile(fileName); }; wb.Execute(); }
/// <summary> /// Returns info on an exception /// </summary> private static ExceptionInfo GetExceptionInfo(Exception e) { ExceptionInfo output = null; var frame = new StackTrace(e, true).GetFrame(0); if (frame != null) { var method = frame.GetMethod(); output = new ExceptionInfo { originMethod = (method != null ? (method.DeclaringType != null ? method.DeclaringType.ToString() : "?") + "." + method.Name : "?") + "()", originLine = frame.GetFileLineNumber(), originVersion = AssemblyInfo.Version, UUID = User.UniqueId, message = e.Message, fullException = e.ToString() }; } if (output == null) output = new ExceptionInfo { originMethod = Utils.CalculateMd5Hash(e.Message), originVersion = AssemblyInfo.Version, UUID = User.UniqueId, message = e.Message, fullException = e.ToString() }; return output; }