From 0c1e9731b2093d99e497bb96c3d824f1bfb19557 Mon Sep 17 00:00:00 2001 From: Tejas Jamdade Date: Fri, 27 May 2022 15:32:42 +0530 Subject: [PATCH] Fix #536 Update error messages for 'caliper-cli' package (#1348) * Update error messages for 'bind'/'unbind' command Signed-off-by: Tezas-6174 * Update error messages for 'launch worker' command Signed-off-by: Tezas-6174 * Update error messages for 'launch manager' command Signed-off-by: Tezas-6174 * Update error message for 'launch' command Signed-off-by: Tezas-6174 * Remove unnecessary debug logs Signed-off-by: Tezas-6174 --- packages/caliper-cli/caliper.js | 4 +++- .../caliper-cli/lib/launch/lib/launchManager.js | 4 ++-- packages/caliper-cli/lib/launch/lib/launchWorker.js | 2 +- packages/caliper-cli/lib/launchCommand.js | 2 +- packages/caliper-cli/lib/lib/bindCommon.js | 13 +++++++------ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/caliper-cli/caliper.js b/packages/caliper-cli/caliper.js index 924bc406c..8accb1d0a 100755 --- a/packages/caliper-cli/caliper.js +++ b/packages/caliper-cli/caliper.js @@ -38,8 +38,10 @@ let results = yargs .strict(false) .argv; + + if (!results.thePromise) { - Logger.error(`Unrecognised command: '${results._[0]}'`); + Logger.error(`Command not recognised: '${results._[0]}'`); process.exit(1); } diff --git a/packages/caliper-cli/lib/launch/lib/launchManager.js b/packages/caliper-cli/lib/launch/lib/launchManager.js index 142a6d2a7..e7f01a8b8 100644 --- a/packages/caliper-cli/lib/launch/lib/launchManager.js +++ b/packages/caliper-cli/lib/launch/lib/launchManager.js @@ -62,10 +62,10 @@ class LaunchManager { const response = await engine.run(); if (response === 0) { - logger.info('Benchmark successfully finished'); + logger.info('Benchmark successfully finished!'); } else { knownError = true; - let msg = `Benchmark failed with error code ${response}`; + let msg = `Benchmark execution failed with error code: ${response}`; logger.error(msg); throw new Error(msg); } diff --git a/packages/caliper-cli/lib/launch/lib/launchWorker.js b/packages/caliper-cli/lib/launch/lib/launchWorker.js index b64710f6c..9b294eef6 100644 --- a/packages/caliper-cli/lib/launch/lib/launchWorker.js +++ b/packages/caliper-cli/lib/launch/lib/launchWorker.js @@ -40,7 +40,7 @@ class LaunchWorker { if (bindingSpec) { if (CaliperUtils.isForkedProcess()) { - logger.info('Worker is a locally forked process, skipping binding step already performed by the manager process'); + logger.info('Worker is a locally forked process, skipping the binding step, already performed by the manager process'); } else { logger.info(`Binding specification is present, performing binding for "${bindingSpec}"`); diff --git a/packages/caliper-cli/lib/launchCommand.js b/packages/caliper-cli/lib/launchCommand.js index ece201840..fe53642ca 100644 --- a/packages/caliper-cli/lib/launchCommand.js +++ b/packages/caliper-cli/lib/launchCommand.js @@ -18,6 +18,6 @@ module.exports.command = 'launch '; module.exports.describe = 'Launch a Caliper process either in a manager or worker role.'; module.exports.builder = yargs => { return yargs - .demandCommand(1, 'Incorrect command. Please see the list of commands above, or enter "caliper launch --help".') + .demandCommand(1, 'Command not found! Please check the list of commands given above, or try running "caliper launch --help".') .commandDir('./launch'); }; diff --git a/packages/caliper-cli/lib/lib/bindCommon.js b/packages/caliper-cli/lib/lib/bindCommon.js index 7971b1e01..37351792a 100644 --- a/packages/caliper-cli/lib/lib/bindCommon.js +++ b/packages/caliper-cli/lib/lib/bindCommon.js @@ -42,7 +42,7 @@ class BindCommon { let sutSpecParts = sutSpec.split(':'); if (sutSpecParts.length < 1 || sutSpecParts.length > 2) { - let msg = `SUT specification is expected in the : format, not as "${sutSpec}"`; + let msg = `The expected SUT specification format is : format, not as "${sutSpec}"`; logger.error(msg); throw new Error(msg); } @@ -50,7 +50,7 @@ class BindCommon { let sut = sutSpecParts[0]; let sdk = sutSpecParts[1]; if (!sdk) { - logger.warn('SUT SDK version is not specified, defaulting to "latest"'); + logger.warn('SUT SDK version is not specified, defaulting to the "latest" version'); sdk = 'latest'; } @@ -63,7 +63,7 @@ class BindCommon { // User has passed a configuration file to bind file = CaliperUtils.resolvePath(file); if (!fs.existsSync(file)) { - let msg = `Passed custom configuration file "${file}" does not exist`; + let msg = `The passed custom configuration file "${file}" does not exist`; logger.error(msg); throw new Error(msg); } else { @@ -90,7 +90,7 @@ class BindCommon { } if (!cwd) { - logger.warn(`Working directory not specified. Using "${path.resolve('./')}"`); + logger.warn(`Working directory is not specified. Current path: "${path.resolve('./')}"`); cwd = path.resolve('./'); } else { cwd = path.resolve(cwd); @@ -106,14 +106,15 @@ class BindCommon { // select the first matching setting, if any if (extraSpec.settings) { let nodeVersion; - logger.info('Querying node version'); + logger.info('Querying node version...'); try { nodeVersion = await CaliperUtils.getCommandOutput('node', ['-v']); } catch (e) { + logger.error(`Node version not found! Version queried: ${nodeVersion}`); logger.error(e.message); throw e; } - logger.info(`Detected node version ${nodeVersion}`); + logger.info(`Detected node version: ${nodeVersion}`); for (let setting of extraSpec.settings) { let regex = new RegExp(setting.versionRegexp, 'g');