summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/ot/editor-socketio-server.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/ot/editor-socketio-server.js b/lib/ot/editor-socketio-server.js
index aae156fc..ade8fc52 100755
--- a/lib/ot/editor-socketio-server.js
+++ b/lib/ot/editor-socketio-server.js
@@ -8,6 +8,7 @@ var Selection = require('./selection');
var util = require('util');
var LZString = require('lz-string');
+var logger = require('../logger');
function EditorSocketIOServer(document, operations, docId, mayWrite) {
EventEmitter.call(this);
@@ -47,7 +48,11 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
console.log("User doesn't have the right to edit.");
return;
}
- self.onOperation(socket, revision, operation, selection);
+ try {
+ self.onOperation(socket, revision, operation, selection);
+ } catch (err) {
+ socket.disconnect();
+ }
});
});
socket.on('get_operations', function (base, head) {
@@ -82,8 +87,9 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati
selection && Selection.fromJSON(selection)
);
} catch (exc) {
- console.error("Invalid operation received: " + exc);
- return;
+ logger.error("Invalid operation received: ");
+ logger.error(exc);
+ throw new Error(exc);
}
try {
@@ -99,7 +105,8 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati
);
this.isDirty = true;
} catch (exc) {
- console.error(exc);
+ logger.error(exc);
+ throw new Error(exc);
}
};