Trace more Sentry errors

This commit is contained in:
Kamil Trzciński 2022-12-14 11:48:02 +01:00
parent b99849675c
commit 8630eb175e
2 changed files with 14 additions and 2 deletions

View file

@ -155,7 +155,7 @@ namespace CommonHelpers
{
if (!runOnceMutex.WaitOne(runOnceTimeout))
{
Fatal(title, "Run many times");
Fatal(title, "Run many times", false);
}
}
catch (AbandonedMutexException)
@ -249,8 +249,10 @@ namespace CommonHelpers
catch { }
}
public static void Fatal(String? title, String message)
public static void Fatal(String? title, String message, bool capture = true)
{
if (capture)
Log.TraceError("FATAL: {0}", message);
if (title is not null)
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);

View file

@ -47,6 +47,16 @@ namespace CommonHelpers
Console.WriteLine(line);
}
public static void TraceError(string format, params object?[] arg)
{
String line = string.Format(format, arg);
Sentry.SentrySdk.CaptureMessage(line, Sentry.SentryLevel.Error);
if (LogToTrace)
Trace.WriteLine(line);
if (LogToConsole)
Console.WriteLine(line);
}
public static void TraceException(String type, Object? name, Exception e)
{
TraceLine("{0}: {1}: Exception: {2}", type, name, e);