CharlieHess / slack-poker-bot

A bot that deals Texas Hold'em games in Slack
MIT License
1.66k stars 206 forks source link

[Feature] Provide feedback when Slack token is wrong #56

Closed stephenyeargin closed 1 year ago

stephenyeargin commented 8 years ago

Lost quite a bit of time debugging while trying to update our bot today. If you provide a bogus (read: somebody regenerated it) SLACK_POKER_BOT_TOKEN, the error output isn't terribly descriptive as to why the application refuses to start.

Ideally, a sanity check would be done on initialization to verify that the token can actually connect to the API. If not, the logs should contain a descriptive "Invalid token, please check your credentials." message instead of Uncaught, unspecified "error" event.

2015-12-02T18:20:00.718608+00:00 heroku[web.1]: Starting process with command `npm start`
2015-12-02T18:20:03.643019+00:00 app[web.1]: 
2015-12-02T18:20:03.643031+00:00 app[web.1]: > slack-poker-bot@1.0.0 start /app
2015-12-02T18:20:03.643032+00:00 app[web.1]: > node src/main.js
2015-12-02T18:20:03.643033+00:00 app[web.1]: 
2015-12-02T18:20:09.833272+00:00 app[web.1]: events.js:87
2015-12-02T18:20:09.833276+00:00 app[web.1]:       throw Error('Uncaught, unspecified "error" event.');
2015-12-02T18:20:09.833277+00:00 app[web.1]:             ^
2015-12-02T18:20:09.833279+00:00 app[web.1]: Error: Uncaught, unspecified "error" event.
2015-12-02T18:20:09.833279+00:00 app[web.1]:     at Error (native)
2015-12-02T18:20:09.833280+00:00 app[web.1]:     at Client.emit (events.js:87:13)
2015-12-02T18:20:09.833282+00:00 app[web.1]:     at Client._onLogin (/app/node_modules/slack-client/src/client.js:74:14)
2015-12-02T18:20:09.833283+00:00 app[web.1]:     at /app/node_modules/slack-client/src/client.js:2:59
2015-12-02T18:20:09.833284+00:00 app[web.1]:     at IncomingMessage.<anonymous> (/app/node_modules/slack-client/src/client.js:670:22)
2015-12-02T18:20:09.833284+00:00 app[web.1]:     at IncomingMessage.emit (events.js:129:20)
2015-12-02T18:20:09.718519+00:00 app[web.1]: [Wed Dec 02 2015 18:20:09 GMT+0000 (UTC)] INFO Connecting...
2015-12-02T18:20:09.866927+00:00 app[web.1]: npm ERR! Linux 3.13.0-66-generic
2015-12-02T18:20:09.867429+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-12-02T18:20:09.867728+00:00 app[web.1]: npm ERR! node v0.12.7
2015-12-02T18:20:09.833285+00:00 app[web.1]:     at _stream_readable.js:908:16
2015-12-02T18:20:09.833286+00:00 app[web.1]:     at process._tickCallback (node.js:355:11)
2015-12-02T18:20:09.862903+00:00 app[web.1]: 
2015-12-02T18:20:09.873029+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-12-02T18:20:09.873184+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2015-12-02T18:20:09.868218+00:00 app[web.1]: npm ERR! npm  v2.11.3
2015-12-02T18:20:09.868462+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-12-02T18:20:09.868676+00:00 app[web.1]: npm ERR! slack-poker-bot@1.0.0 start: `node src/main.js`
2015-12-02T18:20:09.868843+00:00 app[web.1]: npm ERR! Exit status 1
2015-12-02T18:20:09.869045+00:00 app[web.1]: npm ERR! 
2015-12-02T18:20:09.869227+00:00 app[web.1]: npm ERR! Failed at the slack-poker-bot@1.0.0 start script 'node src/main.js'.
2015-12-02T18:20:09.869432+00:00 app[web.1]: npm ERR! This is most likely a problem with the slack-poker-bot package,
2015-12-02T18:20:09.869598+00:00 app[web.1]: npm ERR! not with npm itself.
2015-12-02T18:20:09.869768+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-12-02T18:20:09.869941+00:00 app[web.1]: npm ERR!     node src/main.js
2015-12-02T18:20:09.870104+00:00 app[web.1]: npm ERR! You can get their info via:
2015-12-02T18:20:09.870271+00:00 app[web.1]: npm ERR!     npm owner ls slack-poker-bot
2015-12-02T18:20:09.870438+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
verveguy commented 4 years ago

I've addressed this fairly directly in my verveguy/slack-poker-bot fork by catching the auth error and reporting [INFO] @slack/client:RTMClient:3 unable to RTM start: An API error occurred: invalid_auth logger.js:54 Slack authentication failed. Check that your SLACK_POKER_BOT_TOKEN is valid

Adequate?