diff --git a/src/status.ts b/src/status.ts index eb19e10..ed81a9a 100644 --- a/src/status.ts +++ b/src/status.ts @@ -24,10 +24,17 @@ export async function activateStatusBar({ async function updateStsatusBarItem(): Promise { const output = await runMsgfmtStatistics(); - if (output) { - statusBarItem.text = output; - statusBarItem.show(); - } else { + try { + if (output) { + statusBarItem.text = output; + + statusBarItem.show(); + } else { + statusBarItem.hide(); + } + } catch (error) { + console.error(error); + statusBarItem.hide(); } } @@ -44,9 +51,7 @@ async function runMsgfmtStatistics(): Promise { return new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { if (error) { - console.error(stderr); - - reject(error); + reject(new Error(`Failed to run msgfmt: ${error.message}`)); } else { // Correct. The command will print the statistics to stderr. resolve(stderr);