mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Append stdErr log to error message when a streamed console command fails. (#7868)
This commit is contained in:
@@ -66,20 +66,29 @@ export function executeStreamedCommand(cmd: string, options: childProcess.SpawnO
|
|||||||
let child = childProcess.spawn(cmd, [], options);
|
let child = childProcess.spawn(cmd, [], options);
|
||||||
|
|
||||||
// Add listeners to resolve/reject the promise on exit
|
// 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) => {
|
child.on('exit', (code: number) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} 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
|
// Add listeners to print stdout and stderr if an output channel was provided
|
||||||
if (outputChannel) {
|
if (outputChannel) {
|
||||||
child.stdout.on('data', data => { outputDataChunk(data, outputChannel, ' stdout: '); });
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ export class PerFolderServerInstance implements IServerInstance {
|
|||||||
let onErrorBeforeStartup = (err: any) => reject(err);
|
let onErrorBeforeStartup = (err: any) => reject(err);
|
||||||
let onExitBeforeStart = (err: any) => {
|
let onExitBeforeStart = (err: any) => {
|
||||||
if (!this.isStarted) {
|
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);
|
this.childProcess.on('error', onErrorBeforeStartup);
|
||||||
|
|||||||
Reference in New Issue
Block a user