Skip to content

Commit

Permalink
STCLI-240 thoroughly log errors (#340)
Browse files Browse the repository at this point in the history
Log errors before throwing a simplified message. This detail facilitates
debugging while still providing a user-friendly error message.

Refs STCLI-240
  • Loading branch information
zburke authored Oct 19, 2023
1 parent 6b4903b commit ec3dc1b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 3.1.0 IN PROGRESS

* Log additional error details. Refs STCLI-240.

## [3.0.0](https://github.com/folio-org/stripes-cli/tree/v3.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-cli/compare/v2.7.0...v3.0.0)

Expand Down
1 change: 1 addition & 0 deletions lib/cli/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function loadXml(filePath) {
const data = fs.readFileSync(filePath, 'utf-8');
xml = (new XMLParser()).parse(data);
} catch (err) {
console.error('Something went wrong reading or parsing the XML file.');
console.log(err);
}
return xml;
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/global-dirs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function isYarnVersion(version) {
logger.log('Yarn version', yarnVersion);
return semver.satisfies(yarnVersion, version);
} catch (err) {
logger.log('Unable to determine Yarn version.', err);
logger.error('Unable to determine Yarn version.', err);
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/cli/stripes-config-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function loadStripesConfig(stripesConfigFile) {
try {
config = require(path.resolve(stripesConfigFile)); // eslint-disable-line
} catch (err) {
console.error(err);
throw new StripesCliError(`Unable to load ${stripesConfigFile}`);
}
return config;
Expand Down
1 change: 1 addition & 0 deletions lib/commands/mod/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function installModulesCommand(argv) {
try {
console.log(JSON.stringify(response, null, 2));
} catch (err) {
console.error(err);
console.log(response);
}
})
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/translate/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const createOutDir = (outDir) => {
fs.mkdirSync(outDir);
} catch (err) {
console.error(`Could not create the output directory ${outDir}`);
console.error(err);
console.info(err);
process.exit(1);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/create-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ async function createApp(appName, appDescription) {
results.forEach(result => updateTemplate(result, args));
console.log('App created successfully');
} catch (err) {
console.log(err.stack);
console.error('Something went wrong while creating the app.');
console.info(err);
}

return args;
Expand Down
2 changes: 1 addition & 1 deletion lib/stripes-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ try {
.parse();
} catch (err) {
if (err instanceof AliasError) {
console.log(`Alias Error: ${err.message}`);
console.error(`Alias Error: ${err.message}`);
} else {
throw err;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/test/setup-bigtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ async function setupBigTest() {
fs.removeSync(localTemp);
console.log('BigTest setup successfully');
}).catch((err) => {
console.log(err.stack);
console.error('Error setting up BigTest');
console.info(err);
});
}

Expand Down

0 comments on commit ec3dc1b

Please sign in to comment.