Skip to content

Commit

Permalink
Fix #536 Update error messages for 'caliper-cli' package (#1348)
Browse files Browse the repository at this point in the history
* Update error messages for 'bind'/'unbind' command

Signed-off-by: Tezas-6174 <jamdade.2@iitj.ac.in>

* Update error messages for 'launch worker' command

Signed-off-by: Tezas-6174 <jamdade.2@iitj.ac.in>

* Update error messages for 'launch manager' command

Signed-off-by: Tezas-6174 <jamdade.2@iitj.ac.in>

* Update error message for 'launch' command

Signed-off-by: Tezas-6174 <jamdade.2@iitj.ac.in>

* Remove unnecessary debug logs

Signed-off-by: Tezas-6174 <jamdade.2@iitj.ac.in>
  • Loading branch information
0xt3j4s committed May 27, 2022
1 parent e38c05a commit 0c1e973
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/caliper-cli/caliper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/caliper-cli/lib/launch/lib/launchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/caliper-cli/lib/launch/lib/launchWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`);
Expand Down
2 changes: 1 addition & 1 deletion packages/caliper-cli/lib/launchCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ module.exports.command = 'launch <subcommand>';
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');
};
13 changes: 7 additions & 6 deletions packages/caliper-cli/lib/lib/bindCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class BindCommon {

let sutSpecParts = sutSpec.split(':');
if (sutSpecParts.length < 1 || sutSpecParts.length > 2) {
let msg = `SUT specification is expected in the <SUT type>:<SDK version> format, not as "${sutSpec}"`;
let msg = `The expected SUT specification format is <SUT type>:<SDK version> format, not as "${sutSpec}"`;
logger.error(msg);
throw new Error(msg);
}

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';
}

Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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');
Expand Down

0 comments on commit 0c1e973

Please sign in to comment.