From 38acced902f014ec89531d0e4ff47e7bb07b9252 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 25 Feb 2021 12:35:57 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20support=20api=5Ferrors?= =?UTF-8?q?=20and=20drop=20errors=20format=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/desktop/electron-app/src/boundary-cli.js | 7 +++++-- ui/desktop/electron-app/src/spawn-promise.js | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ui/desktop/electron-app/src/boundary-cli.js b/ui/desktop/electron-app/src/boundary-cli.js index 2227687ed..e42255ea4 100644 --- a/ui/desktop/electron-app/src/boundary-cli.js +++ b/ui/desktop/electron-app/src/boundary-cli.js @@ -18,8 +18,10 @@ const escapeAndValidateBase62 = (str) => { }; module.exports = { + // Check boundary cli existence exists: () => Boolean(cliPath()), + // Initiate connection and return output connect: (target_id, token, host_id) => { const addr = origin.origin; @@ -33,13 +35,13 @@ module.exports = { `-target-id=${sanitized.target_id}`, `-token=${sanitized.token}`, `-addr=${addr}`, - '-format=json', - '--output-json-errors' + '-format=json' ]; if (host_id) command.push(`-host-id=${sanitized.host_id}`) return spawnAsyncJSONPromise(command); }, + // Returns JSON-formatted version information from the CLI version: () => { const command = [ '-v' ]; @@ -54,4 +56,5 @@ module.exports = { return { gitRevision, versionNumber, formatted }; return rawOutput; } + } diff --git a/ui/desktop/electron-app/src/spawn-promise.js b/ui/desktop/electron-app/src/spawn-promise.js index ba08e2685..47afae96d 100644 --- a/ui/desktop/electron-app/src/spawn-promise.js +++ b/ui/desktop/electron-app/src/spawn-promise.js @@ -52,8 +52,10 @@ module.exports = { childProcess.stderr.on('data', (data) => { errorStream += data.toString(); const jsonData = jsonify(errorStream); - const error = jsonData ? jsonData.error : undefined; - if (jsonData) reject(new Error(error)); + if (jsonData) { + const error = jsonData.api_error || jsonData.error; + reject(new Error(error)); + } }); }); },