Skip to content

Commit 423a70b

Browse files
jakebaileyAlexanderSher
authored andcommitted
Catch exceptions when importing from search paths (microsoft#525)
* catch exceptions when importing from search paths * retry instead of not found
1 parent 00aebad commit 423a70b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Analysis/Engine/Impl/Interpreter/Ast/AstModuleResolution.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ public async Task<TryImportModuleResult> TryImportModuleAsync(string name, PathR
205205
} catch (OperationCanceledException) {
206206
_log?.Log(TraceLevel.Error, "ImportTimeout", name, "ImportFromSearchPaths");
207207
return TryImportModuleResult.Timeout;
208+
} catch (Exception ex) when (
209+
ex is IOException // FileNotFoundException, DirectoryNotFoundException, PathTooLongException, etc
210+
|| ex is UnauthorizedAccessException
211+
) {
212+
_log?.Log(TraceLevel.Error, "ImportException", name, "ImportFromSearchPaths", ex.GetType().Name, ex.Message);
213+
return TryImportModuleResult.NeedRetry;
208214
}
209215
}
210216

0 commit comments

Comments
 (0)