Skip to content

Commit 2f9fc3e

Browse files
committed
Read error message from stderr in New Component command
1 parent 0ea1753 commit 2f9fc3e

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/odo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class OdoImpl implements Odo {
345345
public async getServiceTemplates(): Promise<string[]> {
346346
const result: cliInstance.CliExitData = await this.execute(Command.listCatalogServices(), process.cwd(), false);
347347
if (result.error) {
348-
throw new Error(result.stdout.trim());
348+
throw new Error(result.stderr.trim());
349349
}
350350
return result.stdout.trim().split('\n').slice(1).map((value) => value.trim().replace(/\s{1,}/g, '|').split('|')[0]);
351351
}

test/odo.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ suite("odo", () => {
219219
expect(result).empty;
220220
});
221221

222-
test('getServiceTemplates trows exception if service catalog is not enabled', async () => {
223-
const stdout = 'error message';
224-
execStub.resolves({error: new Error(), stdout, stderr: ''});
225-
let e;
222+
test('getServiceTemplates throws exception if service catalog is not enabled', async () => {
223+
const stderr = 'error message';
224+
execStub.resolves({error: new Error(), stdout: '', stderr});
225+
let e: Error;
226226
try {
227227
await odoCli.getServiceTemplates();
228228
} catch (err) {
@@ -231,7 +231,7 @@ suite("odo", () => {
231231

232232
expect(e, 'getServiceTemplates has not threw error').is.not.undefined;
233233
expect(e.message, 'error has no message fields').is.not.undefined;
234-
expect(e.message, 'message is not equal stdout stream output').equals(stdout);
234+
expect(e.message, 'message is not equal stdout stream output').equals(stderr);
235235

236236
});
237237

0 commit comments

Comments
 (0)