Skip to content

Commit

Permalink
Log errors to output channel instead of a toast message
Browse files Browse the repository at this point in the history
  • Loading branch information
gediminasz committed Nov 5, 2023
1 parent a50719b commit 537421b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ function findField(tags, prefix) {
return tag && tag.substring(prefix.length);
}

const outputChannel = vscode.window.createOutputChannel(EXTENSION_NAME);

function wrapExec(exec, platform = process.platform) {
const outputChannel = vscode.window.createOutputChannel(EXTENSION_NAME);
return async (command, options) => {
try {
if (platform === "win32") {
// Use PowerShell on Windows because Command Prompt does not support single quotes
options = {...options, shell: "powershell.exe"}
options = { ...options, shell: "powershell.exe" };
}

outputChannel.appendLine(`${command} ${JSON.stringify(options)}`);
Expand All @@ -114,7 +115,7 @@ function wrapExec(exec, platform = process.platform) {
const output = stdout.trim();
return output ? output.split('\n') : [];
} catch ({ message }) {
vscode.window.showErrorMessage(`${EXTENSION_NAME}: ${message}`);
outputChannel.appendLine(message);
return [];
}
};
Expand Down

0 comments on commit 537421b

Please sign in to comment.