Skip to content

Commit

Permalink
extra try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
filipw committed May 18, 2017
1 parent 76906f9 commit 0cbaf04
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/OmniSharp.Host/Services/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,26 @@ public IReadOnlyList<Assembly> LoadAllFrom(string folderPath)
{
if (string.IsNullOrWhiteSpace(folderPath)) return Array.Empty<Assembly>();

if (!Directory.Exists(folderPath))
try
{
_logger.LogWarning($"Attempted to load assemblies from '{folderPath}' but that path doesn't exist.");
return Array.Empty<Assembly>();
}
var assemblies = new List<Assembly>();

var assemblies = new List<Assembly>();
foreach (var filePath in Directory.EnumerateFiles(folderPath, "*.dll"))
{
var assembly = LoadFromPath(filePath);
if (assembly != null)
foreach (var filePath in Directory.EnumerateFiles(folderPath, "*.dll"))
{
assemblies.Add(assembly);
var assembly = LoadFromPath(filePath);
if (assembly != null)
{
assemblies.Add(assembly);
}
}
}

return assemblies;
return assemblies;
}
catch (Exception ex)
{
_logger.LogError(ex, $"An error occurred when attempting to access '{folderPath}'.");
return Array.Empty<Assembly>();
}
}

private Assembly LoadFromPath(string assemblyPath)
Expand Down

0 comments on commit 0cbaf04

Please sign in to comment.