catch Meteor error on userLeaving

This commit is contained in:
Anton Georgiev 2017-05-17 15:17:27 -04:00
parent 746ef9478c
commit 71d4e8b0e0
3 changed files with 15 additions and 4 deletions

View File

@ -28,8 +28,8 @@ export default function userLeaving(credentials, userId) {
const User = Users.findOne(selector);
if (!User) {
Logger.warn(`Could not find ${userId} in ${meetingId}: cannot complete userLeaving action`);
return;
throw new Meteor.Error(
'user-not-found', `Could not find ${userId} in ${meetingId}: cannot complete userLeaving`);
}
if (User.user.connection_status === OFFLINE_CONNECTION_STATUS) {

View File

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { isAllowedTo } from '/imports/startup/server/userPermissions';
import Logger from '/imports/startup/server/logger';
import userLeaving from './userLeaving';
@ -10,5 +11,10 @@ export default function userLogout(credentials) {
const { requesterUserId } = credentials;
return userLeaving(credentials, requesterUserId);
try {
userLeaving(credentials, requesterUserId);
}
catch(e) {
Logger.error(`Exception while executing userLeaving: ${e}`);
}
};

View File

@ -40,7 +40,12 @@ Meteor.publish('users', function (credentials) {
}
this.onStop(() => {
userLeaving(credentials, requesterUserId);
try {
userLeaving(credentials, requesterUserId);
}
catch(e) {
Logger.error(`Exception while executing userLeaving: ${e}`);
}
});
const selector = {