Skip to content

Commit

Permalink
[minor] Throw a human readable error if the client has not been compi…
Browse files Browse the repository at this point in the history
…led correctly
  • Loading branch information
lpinca committed Feb 17, 2014
1 parent 448ae3f commit eeaefe3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions primus.js
Expand Up @@ -231,6 +231,11 @@ try {
*/ */
function Primus(url, options) { function Primus(url, options) {
if (!(this instanceof Primus)) return new Primus(url, options); if (!(this instanceof Primus)) return new Primus(url, options);
if ('function' !== typeof this.client) {
var message = 'The client library has not been compiled correctly, ' +
'see https://github.com/primus/primus#client-library for more details';
return this.critical(new Error(message));
}


if ('object' === typeof url) { if ('object' === typeof url) {
options = url; options = url;
Expand Down Expand Up @@ -405,12 +410,12 @@ try {
// and guess at a value from the 'href' value // and guess at a value from the 'href' value
// //
if (!data.port) { if (!data.port) {
if (!data.href) data.href = ''; if (!data.href) data.href = '';
if ((data.href.match(/\:/g) || []).length > 1) { if ((data.href.match(/\:/g) || []).length > 1) {
data.port = data.href.split(':')[2].split('/')[0]; data.port = data.href.split(':')[2].split('/')[0];
} else { } else {
data.port = ('https' === data.href.substr(0, 5)) ? 443 : 80; data.port = ('https' === data.href.substr(0, 5)) ? 443 : 80;
} }
} }


// //
Expand Down

0 comments on commit eeaefe3

Please sign in to comment.