Add exceptions for unauth and arg not found when searching

This commit is contained in:
Jeremy Wu 2019-12-09 08:27:50 +11:00
parent ddbf23df68
commit f05767afe8

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -157,6 +157,8 @@ namespace Wox.Plugin.Folder
incompleteName = incompleteName.Substring(1); incompleteName = incompleteName.Substring(1);
} }
try
{
// search folder and add results // search folder and add results
var fileSystemInfos = directoryInfo.GetFileSystemInfos(incompleteName, searchOption); var fileSystemInfos = directoryInfo.GetFileSystemInfos(incompleteName, searchOption);
@ -170,6 +172,18 @@ namespace Wox.Plugin.Folder
: CreateFileResult(fileSystemInfo.FullName); : CreateFileResult(fileSystemInfo.FullName);
results.Add(result); results.Add(result);
} }
}
catch(Exception e)
{
if (e is UnauthorizedAccessException || e is ArgumentException)
{
results.Add(new Result { Title = e.Message, Score = 501 });
return results;
}
throw;
}
return results; return results;
} }