Skip to content

Commit

Permalink
Adding some helpful errors for missing environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jgable committed Jul 19, 2012
1 parent 182f145 commit a6fc4a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/irc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,19 @@ class IrcBot extends Adapter
command: (command, strings...) ->
@bot.send command, strings...

checkCanStart: ->
if not process.env.HUBOT_IRC_NICK or @robot.name
throw new Error("HUBOT_IRC_NICK is not defined; try: export HUBOT_IRC_NICK='mybot'")
else if not process.env.HUBOT_IRC_ROOMS
throw new Error("HUBOT_IRC_ROOMS is not defined; try: export HUBOT_IRC_ROOMS='#myroom'")
else if not process.env.HUBOT_IRC_SERVER
throw new Error("HUBOT_IRC_SERVER is not defined: try: export HUBOT_IRC_SERVER='irc.myserver.com'")

run: ->
self = @

do @checkCanStart

options =
nick: process.env.HUBOT_IRC_NICK or @robot.name
port: process.env.HUBOT_IRC_PORT
Expand Down

0 comments on commit a6fc4a0

Please sign in to comment.