From 503920532d8e3b76e17cf534164655d23c9c3c5d Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 16 Nov 2019 02:49:44 +0800 Subject: Handle errors when `cargo watch` fails --- editors/code/src/commands/runnables.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 26372c1e8..39e542fb6 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -201,6 +201,11 @@ export async function startCargoWatch( ); return; } + } else if (stderr !== '') { + vscode.window.showErrorMessage( + `Couldn't run \`cargo watch\`: ${stderr}` + ); + return; } const provider = await registerCargoWatchProvider(context.subscriptions); -- cgit v1.2.3 From 4c175fbe8a7bb899b6e32994b96d4f3389c1dccc Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 16 Nov 2019 03:44:38 +0800 Subject: Check exit code of `cargo watch` --- editors/code/src/commands/runnables.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 39e542fb6..93171bc75 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -161,7 +161,7 @@ export async function startCargoWatch( ): Promise { const execPromise = util.promisify(child_process.exec); - const { stderr } = await execPromise('cargo watch --version').catch(e => e); + const { stderr, code = 0 } = await execPromise('cargo watch --version').catch(e => e); if (stderr.includes('no such subcommand: `watch`')) { const msg = @@ -201,9 +201,9 @@ export async function startCargoWatch( ); return; } - } else if (stderr !== '') { + } else if (code !== 0) { vscode.window.showErrorMessage( - `Couldn't run \`cargo watch\`: ${stderr}` + `\`cargo watch\` failed with ${code}: ${stderr}` ); return; } -- cgit v1.2.3 From b4fae56a25a3643198ebe1c3c0d52148cfc49477 Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 16 Nov 2019 18:52:47 +0800 Subject: Fix format --- editors/code/src/commands/runnables.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 93171bc75..ac59bf60d 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -161,7 +161,9 @@ export async function startCargoWatch( ): Promise { const execPromise = util.promisify(child_process.exec); - const { stderr, code = 0 } = await execPromise('cargo watch --version').catch(e => e); + const { stderr, code = 0 } = await execPromise( + 'cargo watch --version' + ).catch(e => e); if (stderr.includes('no such subcommand: `watch`')) { const msg = -- cgit v1.2.3