From 06d67f5ad243e6049aa701327ae0f2f414b0189d Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Wed, 23 Oct 2019 12:38:24 -0700 Subject: [PATCH] Append stdErr log to error message when a streamed console command fails. (#7868) --- extensions/notebook/src/common/utils.ts | 15 ++++++++++++--- extensions/notebook/src/jupyter/serverInstance.ts | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/extensions/notebook/src/common/utils.ts b/extensions/notebook/src/common/utils.ts index fe35694f9a..a58ad20774 100644 --- a/extensions/notebook/src/common/utils.ts +++ b/extensions/notebook/src/common/utils.ts @@ -66,20 +66,29 @@ export function executeStreamedCommand(cmd: string, options: childProcess.SpawnO let child = childProcess.spawn(cmd, [], options); // Add listeners to resolve/reject the promise on exit - child.on('error', reject); + child.on('error', err => { + reject(err); + }); + + let stdErrLog = ''; child.on('exit', (code: number) => { if (code === 0) { resolve(); } else { - reject(localize('executeCommandProcessExited', "Process exited with code {0}", code)); + reject(localize('executeCommandProcessExited', 'Process exited with with error code: {0}. StdErr Output: {1}', code, stdErrLog)); } }); // Add listeners to print stdout and stderr if an output channel was provided if (outputChannel) { child.stdout.on('data', data => { outputDataChunk(data, outputChannel, ' stdout: '); }); - child.stderr.on('data', data => { outputDataChunk(data, outputChannel, ' stderr: '); }); } + child.stderr.on('data', data => { + if (outputChannel) { + outputDataChunk(data, outputChannel, ' stderr: '); + } + stdErrLog += data.toString(); + }); }); } diff --git a/extensions/notebook/src/jupyter/serverInstance.ts b/extensions/notebook/src/jupyter/serverInstance.ts index c9b4f0362e..37c1db5247 100644 --- a/extensions/notebook/src/jupyter/serverInstance.ts +++ b/extensions/notebook/src/jupyter/serverInstance.ts @@ -260,7 +260,7 @@ export class PerFolderServerInstance implements IServerInstance { let onErrorBeforeStartup = (err: any) => reject(err); let onExitBeforeStart = (err: any) => { if (!this.isStarted) { - reject(localize('notebookStartProcessExitPremature', "Notebook process exited prematurely with error: {0}, StdErr Output: {1}", err, stdErrLog)); + reject(localize('notebookStartProcessExitPremature', 'Notebook process exited prematurely with error code: {0}. StdErr Output: {1}', err, stdErrLog)); } }; this.childProcess.on('error', onErrorBeforeStartup);