Skip to content

Commit

Permalink
feat: output error detail
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiboy committed Aug 3, 2019
1 parent 632a41c commit 54a3528
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const dingCLI = _commander.default.version(_package.default.version, '-v, --vers
const jsonParser = new Function('jsonData', `return ${jsonBody}`);
body = jsonParser();
} catch (error) {
console.log(_chalk.default.cyan((error.name || 'Error') + ':'), _chalk.default.grey(error.message));
console.log(_chalk.default.cyan('<type>: '), _chalk.default.grey(msgType));
console.log(_chalk.default.cyan('<jsonBody>: '), _chalk.default.grey(jsonBody));
console.log();
return spinner.fail(_chalk.default.red('<jsonBody> must be a json string'));
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ding-bot-cli",
"version": "0.0.3",
"version": "0.0.4",
"description": "DingTalk robot messages sender",
"main": "only-cli.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const dingCLI = commander

body = jsonParser();
} catch (error) {
console.log(chalk.cyan((error.name || 'Error') + ':'), chalk.grey(error.message));
console.log(chalk.cyan('<type>: '), chalk.grey(msgType));
console.log(chalk.cyan('<jsonBody>: '), chalk.grey(jsonBody));
console.log();

return spinner.fail(chalk.red('<jsonBody> must be a json string'));
}

Expand Down

0 comments on commit 54a3528

Please sign in to comment.