node-slack-events-api icon indicating copy to clipboard operation
node-slack-events-api copied to clipboard

Friendly error messages in example app

Open aoberoi opened this issue 8 years ago • 1 comments

Description

When running the example app greet-and-react with missing environment variables, users may see quite a nasty error like this:

TypeError: SlackStrategy requires a clientSecret option
10:43 AM
    at new SlackStrategy (/rbd/pnpm-volume/ac2b9b2a-b6f4-455c-ba84-a33b4efcbe69/node_modules/.registry.npmjs.org/@aoberoi/passport-slack/1.0.5/node_modules/@aoberoi/passport-slack/dist/strategy.js:131:13)
10:43 AM
Jump to
at Object.<anonymous> (/app/src/index.js:37:14)
10:43 AM
    at Module._compile (internal/modules/cjs/loader.js:688:30)
10:43 AM
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
10:43 AM
    at Module.load (internal/modules/cjs/loader.js:598:32)
10:43 AM
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
10:43 AM
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
10:43 AM
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
10:43 AM
    at startup (internal/bootstrap/node.js:285:19)
10:43 AM
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

This is not very helpful to a new user who is just trying to get things running and hasn't yet followed the next step about setting environment variables. Instead, we should catch the errors from the SlackEventAdapter constructor and the SlackStrategy constructor and output a more friendly error message. The following seems a little more pleasant:

Could not start up the application. Have you set your environment variables correctly yet? See ...

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

aoberoi avatar Nov 19 '18 18:11 aoberoi

https://github.com/slackapi/node-slack-sdk/issues/818

shaydewael avatar Jul 16 '19 20:07 shaydewael