code: function proceedIfDbValid(db, callback) {
    db.head('', function(err) {
      err = error.convertResponseError(err, function(err) {
        if (err && err.statusCode === 404) {
          // Override the error type and mesasge for the DB not found case
          var msg = `Database ${db.config.url.replace(/\/\/.+@/g, '//****:****@')}` +
          `/${db.config.db} does not exist. ` +
          'Check the URL and database name have been specified correctly.';
          var noDBErr = new Error(msg);
          noDBErr.name = 'DatabaseNotFound';
          return noDBErr;
        } else {
          // Delegate to the default error factory if it wasn't a 404
          return error.convertResponseError(err);
        }
      });
      // Callback with or without (i.e. undefined) error
      callback(err);
    });
  }
docs: /*
  Check the referenced database exists and that the credentials used have
  visibility. Callback with a fatal error if there is a problem with the DB.
  @param {string} db - database object
  @param {function(err)} callback - error is undefined if DB exists