mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-04 17:43:42 -04:00
observatory herald (#30)
* WIP: initial commit for observatory herald * Plugin error handling refactor * make error window non-modal * tidy up plugin error handling * first pass for basic herald functionality * corrections for linux env * Use FNV hash directly instead of managing through dictionary/index file * resolve audio queuing issue, switch to personal NetCoreAudio fork * merge cleanup * add enable setting, populate defaults * framework xml doc update * Adjust settings, add style selection, replace locale with demonym in dropdown list. * Test is position is on screen before saving/loading. * use a default that's actually in the list
This commit is contained in:
@ -14,18 +14,32 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
private IEnumerable<IObservatoryWorker> observatoryWorkers;
|
||||
private IEnumerable<IObservatoryNotifier> observatoryNotifiers;
|
||||
private List<string> errorList;
|
||||
|
||||
public PluginEventHandler(IEnumerable<IObservatoryWorker> observatoryWorkers, IEnumerable<IObservatoryNotifier> observatoryNotifiers)
|
||||
{
|
||||
this.observatoryWorkers = observatoryWorkers;
|
||||
this.observatoryNotifiers = observatoryNotifiers;
|
||||
errorList = new();
|
||||
}
|
||||
|
||||
public void OnJournalEvent(object source, JournalEventArgs journalEventArgs)
|
||||
{
|
||||
foreach (var worker in observatoryWorkers)
|
||||
{
|
||||
worker.JournalEvent((JournalBase)journalEventArgs.journalEvent);
|
||||
try
|
||||
{
|
||||
worker.JournalEvent((JournalBase)journalEventArgs.journalEvent);
|
||||
}
|
||||
catch (PluginException ex)
|
||||
{
|
||||
RecordError(ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RecordError(ex, worker.Name, journalEventArgs.journalType.Name);
|
||||
}
|
||||
ReportErrorsIfAny();
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +47,19 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var worker in observatoryWorkers)
|
||||
{
|
||||
worker.StatusChange((Status)journalEventArgs.journalEvent);
|
||||
try
|
||||
{
|
||||
worker.StatusChange((Status)journalEventArgs.journalEvent);
|
||||
}
|
||||
catch (PluginException ex)
|
||||
{
|
||||
RecordError(ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RecordError(ex, worker.Name, journalEventArgs.journalType.Name);
|
||||
}
|
||||
ReportErrorsIfAny();
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +67,39 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var notifier in observatoryNotifiers)
|
||||
{
|
||||
notifier.OnNotificationEvent(notificationArgs);
|
||||
try
|
||||
{
|
||||
notifier.OnNotificationEvent(notificationArgs);
|
||||
}
|
||||
catch (PluginException ex)
|
||||
{
|
||||
RecordError(ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RecordError(ex, notifier.Name, notificationArgs.Title);
|
||||
}
|
||||
ReportErrorsIfAny();
|
||||
}
|
||||
}
|
||||
|
||||
private void RecordError(PluginException ex)
|
||||
{
|
||||
errorList.Add($"Error in {ex.PluginName}: {ex.Message}");
|
||||
}
|
||||
|
||||
private void RecordError(Exception ex, string plugin, string eventType)
|
||||
{
|
||||
errorList.Add($"Error in {plugin} while handling {eventType}: {ex.Message}");
|
||||
}
|
||||
|
||||
private void ReportErrorsIfAny()
|
||||
{
|
||||
if (errorList.Any())
|
||||
{
|
||||
ErrorReporter.ShowErrorPopup($"Plugin Error{(errorList.Count > 1 ? "s" : "")}", string.Join(Environment.NewLine, errorList));
|
||||
|
||||
errorList.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user