       'X-Auth-Token': token
   request.get options, (error, response, body) ->
     if (error)
-      callback(error)
+      d.reject(error)
     else
       domain = _.find body.domains, (domain) ->
         recordName.indexOf(domain.name) != -1

        .pluck 'publicURL'
        .head()
        .value()
      callback null,
        expiry: body.access.token.expires,
        token: body.access.token.id,
        endpoint: designateEndpoint
  d.promise

designateRecords = (token, endpoint, recordName, callback) ->
  options =
    url: endpoint + '/domains'
    json: true

          password: env.OS_PASSWORD
  request.post options, (error, response, body) ->
    if (error)
      d.reject(error)
    else
      designateEndpoint = _.chain(body.access.serviceCatalog)
        .filter (obj) -> obj.type == 'dns'
