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:
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user