diff --git a/dist/cloud.js b/dist/cloud.js index f21470e..9459d20 100644 --- a/dist/cloud.js +++ b/dist/cloud.js @@ -1774,32 +1774,53 @@ * > • (B) it also supports passing in a dictionary in lieu of a function * > for its second argument. If provided, this dictionary will be * > used as a mini-router based around the conventional "verb" - * > property in all incoming socket messages. The special, reserved - * > "*" key, if provided, will be used to handle unmatched - * > socket events (e.g. to allow for custom error handling.) + * > property in all incoming socket messages. In addition, if the + * > special, reserved "error" key is provided with a catchall function, + * > it will be used to handle any socket events that don't match other + * > keys, or that are missing a "verb property" (i.e. to allow for + * > custom error handling-- otherwise, a default error is thrown.) + * > If an "error" key was provided, and a socket message arrives with + * > `verb: 'error'`, then it is still routed as expected. * * @param {String} socketEventName * @param {Function|Dictionary} handleSocketMsg */ Cloud.on = function(socketEventName, handleSocketMsg) { - if (!socketEventName || !_.isString(socketEventName)) { throw new Error('Invalid usage for `Cloud.on()`: Must pass in a valid first argument (a string; the name of the socket event to listen for).'); } - if (!handleSocketMsg) { throw new Error('Invalid usage for `Cloud.on()`: Must pass in a second argument (the function to run every time this socket event is received).'); } + if (!socketEventName || !_.isString(socketEventName)) { throw new Error('Invalid usage for `Cloud.on()`: Must pass in a valid first argument (a string; the name of the socket event to listen for -- i.e. the variety of incoming WebSocket messages to receive and handle).'); } + if (!handleSocketMsg) { throw new Error('Invalid usage for `Cloud.on()`: Must pass in a second argument (the function to run every time this WebSocket event is received).'); } - if (!io || !io.socket) { throw new Error('Could not bind a WebSocket event listener with `Cloud.on()`: Socket support is not currently available (`io.socket` is not available). Make sure `sails.io.js` is being injected in a