Skip to content

Commit cd5c4a7

Browse files
authored
Handle errors when accessing non-existing prompt folders (microsoft#249809)
Error wen accsssing not existing prompts folders
1 parent 28b55a7 commit cd5c4a7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ export class UserToolSetsContributions extends Disposable implements IWorkbenchC
178178

179179
const store = this._store.add(new DisposableStore());
180180

181+
const getFilesInFolder = async (folder: URI) => {
182+
try {
183+
return (await this._fileService.resolve(folder)).children ?? [];
184+
} catch (err) {
185+
return []; // folder does not exist or cannot be read
186+
}
187+
};
188+
181189
this._store.add(autorun(async r => {
182190

183191
store.clear();
@@ -190,14 +198,14 @@ export class UserToolSetsContributions extends Disposable implements IWorkbenchC
190198
const cts = new CancellationTokenSource();
191199
store.add(toDisposable(() => cts.dispose(true)));
192200

193-
const stat = await this._fileService.resolve(uri);
201+
const entries = await getFilesInFolder(uri);
194202

195203
if (cts.token.isCancellationRequested) {
196204
store.clear();
197205
return;
198206
}
199207

200-
for (const entry of stat.children ?? []) {
208+
for (const entry of entries) {
201209

202210
if (!entry.isFile || !RawToolSetsShape.isToolSetFileName(entry.resource)) {
203211
// not interesting

0 commit comments

Comments
 (0)