static void SendCrashDump(CrashData cd) { if (EnableSendCrashDump) { // TODO } }
public CrashData(Exception e, string Username) { this.Username = Username; StackTrace trace = new StackTrace(e, true); StackTraceData = trace.GetFrames().Select((sf) => { return(new StackTraceData { Line = sf.GetFileLineNumber(), Column = sf.GetFileColumnNumber(), Filename = sf.GetFileName(), ClassName = sf.GetMethod().ReflectedType.FullName, Method = sf.GetMethod().Name, }); }).ToList(); ID = Guid.NewGuid().ToString(); ExceptionCode = e.HResult; Source = e.Source; StackTrace = e.StackTrace; ExceptionName = e.GetType().Name; Timestamp = LLTools.TimestampMS(); Date = DateTime.Now.ToLongDateString(); Time = DateTime.Now.ToLongTimeString(); XRITVersion = LibInfo.Version; XRITCommit = LibInfo.CommitID; if (e.InnerException != null) { InnerCrashData = new CrashData(e); } }
public static void Report(Exception e) { var cd = new CrashData(e, Username); try { UIConsole.Error($"Got {cd.ExceptionName} at {cd.Filename}:{cd.Line}"); } catch (Exception) { Console.WriteLine($"Got {cd.ExceptionName} at {cd.Filename}:{cd.Line}"); } SaveCrashDump(cd); SendCrashDump(cd); }
static void SaveCrashDump(CrashData cd) { if (EnableSaveCrashDump) { try { Directory.CreateDirectory(CrashLogFolder); string jsonData = cd.ToJSON(); string filename = $"crashdata-{cd.ExceptionName}-{cd.ID}.json"; try { UIConsole.Error($"Saving Crash Dump to: {filename}"); } catch (Exception) { Console.WriteLine($"Saving Crash Dump to: {filename}"); } File.WriteAllText(Path.Combine(CrashLogFolder, filename), jsonData); } catch (Exception e) { Console.WriteLine("FATAL: Cannot write crash dump: {0}", e); } } }