   name = user.name.replace('@', '')
   resolve_cred = (u) -> u.githubLogin
   resolve_env = (n) -> process.env["HUBOT_GITHUB_USER_#{n.replace(/\s/g, '_').toUpperCase()}"]
-  resolve_cred(user) or resolve_env(name) or resolve_env(name.split(' ')[0]) or name
+  resolve_cred(user) or resolve_env(name) or resolve_env(name.split(' ')[0]) or
+  throw new Error("Sorry, I can't find any GitHub logins for #{name}. You can specify one by telling me 'i am githubusername'.")
 
 # Resolve all parameters for a given subscription/unsubscription request:
 # chat user, qualified GitHub user, kind of notification, repository, qualified GitHub repository.

  # return the array
  userInfos

module.exports = (robot) ->

  github = require('githubot')(robot)

  # handle notification subscriptions
  robot.respond NOTIFY_REGEX, (msg) ->
    params = resolve_params github, msg
    try
      add_notification(robot, params)
      reply = "You will now receive notifications for #{params.kind} #{(if params.qualified_repo? then 'in ' + params.qualified_repo else 'everywhere')}."
    catch error
      reply = error
    finally
      robot.brain.save
    robot.send params.user, reply

  # handle notification unsubscriptions
  robot.respond UNNOTIFY_REGEX, (msg) ->
    params = resolve_params github, msg
    try
      remove_notification(robot, params)
      reply = "You will no longer receive notifications for #{params.kind} #{(if params.qualified_repo? then 'in ' + params.repo else 'anywhere')}."
    catch error
      reply = error
    finally
      robot.brain.save
    robot.send params.user, reply

  # handle notification subscription listing
  robot.respond LIST_REGEX, (msg) ->
    params = resolve_params github, msg, 2
    # get the notifications
    userSettings = _.find(robot.brain.get(GITHUB_NOTIFY_PRE + params.kind), {userName: params.qualified_user}) or {}
    userNotifications = userSettings.userNotifications or []
    # build an appropriate response by joining all checked repositories
    if userNotifications?.length > 0
      s = _.map(userNotifications, (n) ->
        if n is true then 'every repository' else n
      ).join(', ')
      reply = "You will receive notifications for #{params.kind} in #{s}."
    else reply = "You will receive no notifications for #{params.kind}."
    robot.send params.user, reply

  # handle new comments and new issue assignments
  robot.router.post '/hubot/gh-notify', (req, res) ->

# Resolve user name to a potential GitHub username by using, in order:
#   - GitHub credentials as handled by the github-credentials.coffee script
#   - environment variables in the form of HUBOT_GITHUB_USER_.*
#   - throws an Error if the username can't be matched
#
# user - The chat username to be resolved
#
