Expose core error logger to plugins and report custom criteria errors (#78)
* Expose core error logger to plugins and report custom criteria errors Fixes #77 This adds an error logging method on the IObservatoryCore interface that writes the exception details to ObservatoryCore's central error log (found in `${Documents}/ObservatoryErrorLog.txt`). In addition, added a timestamp to each error log. Also updates the Explorer to report Custom Criteria file load errors and execution errors to the log. Also updates HeraldNotifier to report CacheIndex.json parse failures to the error log as well. * Expand debugging/error logging in Herald; cleanup empty mp3 files Herald crashes if attempting to play 0-byte mp3s so if detected, delete, re-request (empty files can occur in some azure failure cases (ie. out of quota). Trap and log errors in other places in HeraldQueue to avoid hard crashes due to weird and wonderful unexpected stuff.
This commit is contained in:
parent
7fe11b8094
commit
ab365cd322
8 changed files with 115 additions and 44 deletions
|
|
@ -12,9 +12,12 @@ namespace Observatory.Explorer
|
|||
{
|
||||
private Lua LuaState;
|
||||
private List<LuaFunction> CriteriaFunctions;
|
||||
|
||||
public CustomCriteriaManager()
|
||||
Action<Exception, String> ErrorLogger;
|
||||
|
||||
|
||||
public CustomCriteriaManager(Action<Exception, String> errorLogger)
|
||||
{
|
||||
ErrorLogger = errorLogger;
|
||||
CriteriaFunctions = new();
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +177,14 @@ namespace Observatory.Explorer
|
|||
|
||||
originalScript = originalScript.Remove(originalScript.LastIndexOf(Environment.NewLine));
|
||||
originalScript = originalScript[(originalScript.IndexOf(Environment.NewLine) + Environment.NewLine.Length)..];
|
||||
|
||||
throw new CriteriaLoadException(e.Message, originalScript.Replace('\t', ' '));
|
||||
originalScript = originalScript.Replace('\t', ' ');
|
||||
|
||||
StringBuilder errorDetail = new();
|
||||
errorDetail.AppendLine("Error Reading Custom Criteria File:")
|
||||
.AppendLine(originalScript)
|
||||
.AppendLine("NOTE: Custom criteria processing has been disable to prevent further errors.");
|
||||
ErrorLogger(e, errorDetail.ToString());
|
||||
throw new CriteriaLoadException(e.Message, originalScript);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -236,6 +245,12 @@ namespace Observatory.Explorer
|
|||
{
|
||||
settings.EnableCustomCriteria = false;
|
||||
results.Add((e.Message, scan.Json, false));
|
||||
|
||||
StringBuilder errorDetail = new();
|
||||
errorDetail.AppendLine("while processing a custom criteria on scan:")
|
||||
.AppendLine(scan.Json)
|
||||
.AppendLine("NOTE: Custom criteria process has been disabled to prevent further errors.");
|
||||
ErrorLogger(e, errorDetail.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Observatory.Explorer
|
|||
ExplorerWorker = explorerWorker;
|
||||
ObservatoryCore = core;
|
||||
Results = results;
|
||||
CustomCriteriaManager = new();
|
||||
CustomCriteriaManager = new(core.GetPluginErrorLogger(explorerWorker));
|
||||
CriteriaLastModified = new DateTime(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue