Skip to content

Commit 5bb5c48

Browse files
authored
fix bug to return empty array when no config exists (#642)
1 parent 6afaa10 commit 5bb5c48

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/extension/debugger/configuration/launch.json/launchJsonReader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export function getConfigurationsFromSettings(workspace: WorkspaceFolder): Debug
5151
!Array.isArray(codeWorkspaceConfig.configurations) ||
5252
codeWorkspaceConfig.configurations.length === 0
5353
) {
54-
throw Error('No configurations found in launch.json or settings.json');
54+
traceLog('No configurations found in settings.json or launch.json.');
55+
return [];
5556
}
5657
traceLog('Using configuration in workspace settings.json.');
5758
return codeWorkspaceConfig.configurations;

src/test/unittest/configuration/launch.json/launchJsonReader.unit.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ suite('Debugging - launchJsonReader', () => {
9696
assert.strictEqual(configurations[0].name, 'Launch Program 3');
9797
});
9898

99-
test('Should error if no configurations in settings.json', () => {
99+
test('Should return empty array if no configurations in settings.json', () => {
100100
const workspace = typemoq.Mock.ofType<WorkspaceFolder>();
101101
workspace.setup((w) => w.uri).returns(() => Uri.file('/path/to/workspace'));
102102

@@ -106,11 +106,8 @@ suite('Debugging - launchJsonReader', () => {
106106

107107
sandbox.stub(vscodeapi, 'getConfiguration').returns(mockConfig.object);
108108

109-
assert.throws(
110-
() => getConfigurationsFromSettings(workspace.object),
111-
Error,
112-
'No configurations found in launch.json or settings.json',
113-
);
109+
const configurations = getConfigurationsFromSettings(workspace.object);
110+
assert.strictEqual(configurations.length, 0);
114111
});
115112
});
116113
});

0 commit comments

Comments
 (0)