Skip to content

Commit

Permalink
improve fatal exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sealsrock12 committed Dec 31, 2022
1 parent e29f69a commit f0a8fce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions client/DebugLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace specify_client;

public static class DebugLog
{
private static string LogFilepath = "specify_debug.log";
public const string LogFilePath = "specify_debug.log";
private static bool Enabled = true;
private static bool Started = false;
private static DateTime LogStartTime { get; set; }
Expand Down Expand Up @@ -45,13 +45,13 @@ public static async Task StartDebugLog()
return;
}
LogStartTime = DateTime.Now;
if(!File.Exists(LogFilepath))
if(!File.Exists(LogFilePath))
{
File.Create(LogFilepath).Close();
File.Create(LogFilePath).Close();
}
else
{
await Task.Run(() => File.WriteAllText(LogFilepath, ""));
await Task.Run(() => File.WriteAllText(LogFilePath, ""));
}
for (int i = 0; i < ErrorCount.Length; i++)
{
Expand Down Expand Up @@ -136,7 +136,7 @@ public static async Task LogEventAsync(string message, Region region = Region.Mi
{
try
{
await Task.Run(() => File.AppendAllText(LogFilepath, debugString));
await Task.Run(() => File.AppendAllText(LogFilePath, debugString));
break;
}
catch
Expand Down Expand Up @@ -171,7 +171,7 @@ public static void LogEvent(string message, Region region = Region.Misc, EventTy
{
try
{
File.AppendAllText(LogFilepath, debugString);
File.AppendAllText(LogFilePath, debugString);
break;
}
catch
Expand Down
7 changes: 5 additions & 2 deletions client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ static async Task Main()
}
catch (Exception ex)
{
Console.WriteLine("A fatal exception has occurred. Please see debug.log for details.");
Settings.EnableDebug = true;
await DebugLog.StartDebugLog();
await DebugLog.LogEventAsync("FATAL EXCEPTION", DebugLog.Region.Misc, DebugLog.EventType.ERROR);
await DebugLog.LogEventAsync(ex.ToString());
System.Threading.Thread.Sleep(10000);
Console.WriteLine($"A fatal exception has occurred. Please see {DebugLog.LogFilePath} for details.");
Console.WriteLine("Press any key to close this window.");
Console.ReadKey(true);
}
}

Expand Down
4 changes: 2 additions & 2 deletions client/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
[assembly: AssemblyTitle("Specify")]
[assembly: AssemblyDescription("Gathers information about your computer. It does not collect any sensitive information.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("specify_client")]
[assembly: AssemblyCompany("Spec-ify")]
[assembly: AssemblyProduct("Specify")]
[assembly: AssemblyCopyright("Copyright © 2022 Specify team")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand Down

0 comments on commit f0a8fce

Please sign in to comment.