Skip to content

Commit 173ddb9

Browse files
author
Dom Harrington
committed
Tidying up how validation errors are logged from the API
1 parent af305f2 commit 173ddb9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/docs.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ exports.run = function({ args, opts }) {
4040

4141
function validationErrors(err) {
4242
if (err.statusCode === 400) {
43-
console.log(err.error);
44-
return Promise.reject();
43+
return Promise.reject(err.error);
4544
}
4645

4746
return Promise.reject(err);

rdme.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ const parseArgs = require('minimist')(process.argv.slice(2), {
1616
require('./cli')(parseArgs._[0], parseArgs._.slice(1), parseArgs)
1717
.then(() => process.exit())
1818
.catch(err => {
19-
if (err) console.error(err.message.red);
20-
if (err.description) console.warn(err.description);
19+
if (err) {
20+
// `err.message` is from locally thrown Error objects
21+
// `err.error` is from remote API errors
22+
console.error((err.message || err.error).red);
23+
if (err.description) console.warn(err.description);
24+
if (err.errors) console.warn(err.errors);
25+
}
26+
2127
return process.exit(1);
2228
});

0 commit comments

Comments
 (0)