2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-07-03 01:03:41 -04:00

Error handling improvements (#92)

* Consolidate plugin errors into single window.

* Handle error aggregation and loggin inside error reporter.

* Minor logging corrections.

* Error popup tweaking
This commit is contained in:
Jonathan Miller
2022-07-24 15:48:55 -02:30
committed by GitHub
parent d8d5f2794b
commit 342d5af11c
7 changed files with 80 additions and 61 deletions

View File

@ -374,42 +374,21 @@ namespace Observatory
{
if (readErrors.Any())
{
var errorContent = new System.Text.StringBuilder();
int count = 0;
foreach (var error in readErrors)
var errorList = readErrors.Select(error =>
{
string message;
if (error.ex.InnerException == null)
{
errorContent.AppendLine(error.ex.Message);
message = error.ex.Message;
}
else
{
errorContent.AppendLine(error.ex.InnerException.Message);
}
errorContent.AppendLine($"File: {error.file}");
if (error.line.Length > 200)
{
errorContent.AppendLine($"Line (first 200 chars): {error.line.Substring(0, 200)}");
}
else
{
errorContent.AppendLine($"Line: {error.line}");
message = error.ex.InnerException.Message;
}
return ($"Error reading file {error.file}: {message}", error.line);
});
if (error != readErrors.Last())
{
errorContent.AppendLine();
if (count++ == 5)
{
errorContent.AppendLine($"There are {readErrors.Count - 6} more errors but let's keep this window manageable.");
break;
}
}
}
Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => ErrorReporter.ShowErrorPopup($"Journal Read Error{(readErrors.Count > 1 ? "s" : "")}", errorContent.ToString()));
ErrorReporter.ShowErrorPopup($"Journal Read Error{(readErrors.Count > 1 ? "s" : "")}", errorList.ToList());
}
}