Skip to content

Commit

Permalink
RealtimePresence: convert Errors to ErrorInfos
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonWoolf committed Jan 14, 2016
1 parent 8f3a02d commit ea53db9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions common/lib/client/realtimepresence.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ var RealtimePresence = (function() {

RealtimePresence.prototype.enter = function(data, callback) {
if(!getClientId(this))
throw new Error('clientId must be specified to enter a presence channel');
throw new ErrorInfo('clientId must be specified to enter a presence channel', 40012, 400);
this._enterOrUpdateClient(undefined, data, callback, 'enter');
};

RealtimePresence.prototype.update = function(data, callback) {
if(!getClientId(this))
throw new Error('clientId must be specified to update presence data');
throw new Error('clientId must be specified to update presence data', 40012, 400);
this._enterOrUpdateClient(undefined, data, callback, 'update');
};

Expand Down Expand Up @@ -97,15 +97,15 @@ var RealtimePresence = (function() {
};
break;
default:
var err = new Error('Unable to ' + action + ' presence channel (incompatible state)');
var err = new ErrorInfo('Unable to ' + action + ' presence channel (incompatible state)', 90001);
err.code = 90001;
callback(err);
}
};

RealtimePresence.prototype.leave = function(data, callback) {
if(!getClientId(this))
throw new Error('clientId must have been specified to enter or leave a presence channel');
throw new ErrorInfo('clientId must have been specified to enter or leave a presence channel', 40012, 400);
this.leaveClient(undefined, data, callback);
};

Expand Down Expand Up @@ -141,8 +141,7 @@ var RealtimePresence = (function() {
/* we're not attached; therefore we let any entered status
* timeout by itself instead of attaching just in order to leave */
this.pendingPresence = null;
var err = new Error('Unable to leave presence channel (incompatible state)');
err.code = 90001;
var err = new ErrorInfo('Unable to leave presence channel (incompatible state)', 90001);
callback(err);
break;
default:
Expand Down

1 comment on commit ea53db9

@paddybyers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I realise those weren't an issue with the present PR, but worth addressing.

Please sign in to comment.