Skip to content

Commit 4f4f9b0

Browse files
Modified the errors produced by debugLauncher.js when launch.json is not configured right (#14739)
* Modified the errors produced when launch.json is not configured right * modified debugLauncher.ts as advised, added news * removed extra file 'entry.txt' * moved news to the correct folder * fixed suggested changes in news text
1 parent 735516a commit 4f4f9b0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

news/3 Code Health/14739.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Modified the errors generated when `launch.json` is not properly configured to be more specific about which fields are missing.
2+
(thanks [Shahzaib Paracha](https://github.com/ShahzaibP))

src/client/testing/common/debugLauncher.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,24 @@ export class DebugLauncher implements ITestDebugLauncher {
5252
if (!(await this.fs.fileExists(filename))) {
5353
return [];
5454
}
55+
5556
try {
5657
const text = await this.fs.readFile(filename);
5758
const parsed = parse(text, [], { allowTrailingComma: true, disallowComments: false });
58-
if (!parsed.version || !parsed.configurations || !Array.isArray(parsed.configurations)) {
59-
throw Error('malformed launch.json');
59+
if (!parsed.configurations || !Array.isArray(parsed.configurations)) {
60+
throw Error('Missing field in launch.json: configurations');
61+
}
62+
if (!parsed.version) {
63+
throw Error('Missing field in launch.json: version');
6064
}
6165
// We do not bother ensuring each item is a DebugConfiguration...
6266
return parsed.configurations;
6367
} catch (exc) {
6468
traceError('could not get debug config', exc);
6569
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
66-
await appShell.showErrorMessage('Could not load unit test config from launch.json');
70+
await appShell.showErrorMessage(
71+
'Could not load unit test config from launch.json as it is missing a field'
72+
);
6773
return [];
6874
}
6975
}

0 commit comments

Comments
 (0)