kata-ai/kata-cli

Add proper error handling when kata versions cannot find bot.yml

girikuncoro opened this issue · 2 comments

Users should not see error tracing and CLI should handle error as many as it can. I was trying to execute kata versions outside my bot directory, and got this:

$ kata versions
[ERROR] kata-cli/undefined 2017-12-02 20:45:53 : { Error: ENOENT: no such file or directory, open './bot.yml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Helper.loadYaml (/usr/local/lib/node_modules/kata-cli/lib/components/scripts/helper.js:39:33)
    at Helper.getBotId (/usr/local/lib/node_modules/kata-cli/lib/components/scripts/helper.js:103:25)
    at Bot.<anonymous> (/usr/local/lib/node_modules/kata-cli/lib/components/bots/bot.js:88:39)
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/kata-cli/lib/components/bots/bot.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/kata-cli/lib/components/bots/bot.js:3:12)
    at Bot.versions (/usr/local/lib/node_modules/kata-cli/lib/components/bots/bot.js:87:16)
    at Command.args (/usr/local/lib/node_modules/kata-cli/lib/components/main.js:93:17)
    at Command.listener (/usr/local/lib/node_modules/kata-cli/node_modules/commander/index.js:315:8)
    at emitTwo (events.js:126:13)
    at Command.emit (events.js:214:7)
    at Command.parseArgs (/usr/local/lib/node_modules/kata-cli/node_modules/commander/index.js:653:12)
    at Command.parse (/usr/local/lib/node_modules/kata-cli/node_modules/commander/index.js:475:21) errno: -2, code: 'ENOENT', syscall: 'open', path: './bot.yml' }

would be nice if CLI returns something like kata versions must be executed in bot directory with bot.yml or alike.

Thanks @girikuncoro
I will working to resolve this issue

Waiting for review in PR #28 @girikuncoro