add logging to Index and DirectoryInfo search

This commit is contained in:
Jeremy Wu 2020-06-08 19:01:32 +10:00
parent 407864beb7
commit a196c4f269
2 changed files with 19 additions and 9 deletions

View file

@ -1,10 +1,9 @@
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin.SharedCommands;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
{
@ -83,7 +82,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
return results;
}
throw;
#if DEBUG // Please investigate and handle error from DirectoryInfo search
throw e;
#else
Log.Exception($"|Flow.Launcher.Plugin.Explorer.DirectoryInfoSearch|Error from performing DirectoryInfoSearch", e);
#endif
}
// Intial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.

View file

@ -1,11 +1,8 @@
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin.SharedCommands;
using Microsoft.Search.Interop;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.OleDb;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
@ -63,13 +60,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
}
}
}
catch (InvalidOperationException)
catch (InvalidOperationException e)
{
// Internal error from ExecuteReader(): Connection closed.
LogException("Internal error from ExecuteReader()", e);
}
catch (Exception ex)
catch (Exception e)
{
Log.Info(ex.ToString());//UPDATE THIS LOGGING
LogException("General error from performing index search", e);
}
return results;
@ -105,5 +103,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
var indexManager = csm.GetCatalog("SystemIndex").GetCrawlScopeManager();
return indexManager.IncludedInCrawlScope(path) > 0;
}
private void LogException(string message, Exception e)
{
#if DEBUG // Please investigate and handle error from index search
throw e;
#else
Log.Exception($"|Flow.Launcher.Plugin.Explorer.IndexSearch|{message}", e);
#endif
}
}
}