Skip to content

Commit 1ea6ea0

Browse files
authored
DefaultWorkspaceManager: improve error handling in traverseFolder (#2047)
1 parent 14554d5 commit 1ea6ea0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

packages/langium/src/workspace/workspace-manager.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,20 @@ export class DefaultWorkspaceManager implements WorkspaceManager {
195195
* contained files that match the file extensions are added to the `uris` array.
196196
*/
197197
protected async traverseFolder(folderPath: URI, uris: URI[]): Promise<void> {
198-
const content = await this.fileSystemProvider.readDirectory(folderPath);
199-
await Promise.all(content.map(async entry => {
200-
if (this.shouldIncludeEntry(entry)) {
201-
if (entry.isDirectory) {
202-
await this.traverseFolder(entry.uri, uris);
203-
} else if (entry.isFile) {
204-
uris.push(entry.uri);
198+
try {
199+
const content = await this.fileSystemProvider.readDirectory(folderPath);
200+
await Promise.all(content.map(async entry => {
201+
if (this.shouldIncludeEntry(entry)) {
202+
if (entry.isDirectory) {
203+
await this.traverseFolder(entry.uri, uris);
204+
} else if (entry.isFile) {
205+
uris.push(entry.uri);
206+
}
205207
}
206-
}
207-
}));
208+
}));
209+
} catch (e) {
210+
console.error('Failure to read directory content of ' + folderPath.toString(true), e);
211+
}
208212
}
209213

210214
async searchFolder(uri: URI): Promise<URI[]> {

0 commit comments

Comments
 (0)