@@ -87,7 +87,7 @@ Topic.formatMessage_ = function(message) {
8787
8888/**
8989 * Format the name of a topic. A Topic's full name is in the format of
90- * 'projects/{projectId}/topics/{topicName}.
90+ * 'projects/{projectId}/topics/{topicName}' .
9191 *
9292 * @private
9393 *
@@ -102,8 +102,8 @@ Topic.formatName_ = function(projectId, name) {
102102} ;
103103
104104/**
105- * Wrapper for makeReq_ that automatically attempts to create a topic if it
106- * does not yet exist.
105+ * Wrapper for makeReq_ that automatically attempts to create a topic if it does
106+ * not yet exist.
107107 *
108108 * @private
109109 */
@@ -130,10 +130,11 @@ Topic.prototype.autoCreateWrapper_ = function(method, path, q, body, callback) {
130130} ;
131131
132132/**
133- * Publish the provided message or array of messages. A message can be of any
134- * type. On success, an array of messageIds is returned in the response.
133+ * Publish the provided message or array of messages. On success, an array of
134+ * messageIds is returned in the response.
135135 *
136136 * @throws {Error } If no message is provided.
137+ * @throws {Error } If a message is missing a data property.
137138 *
138139 * @param {object|object[] } message - The message(s) to publish.
139140 * @param {* } message.data - The contents of the message.
@@ -178,6 +179,10 @@ Topic.prototype.publish = function(messages, callback) {
178179 throw new Error ( 'Cannot publish without a message.' ) ;
179180 }
180181
182+ if ( ! messages . every ( util . prop ( 'data' ) ) ) {
183+ throw new Error ( 'Cannot publish message without a `data` property.' ) ;
184+ }
185+
181186 callback = callback || util . noop ;
182187
183188 var body = {
0 commit comments