[WebsocketController] use a new NotJoinedError

This commit is contained in:
Jakob Ackermann 2020-08-20 13:07:27 +01:00
parent 4cb8cc4a85
commit 0462e3e437
2 changed files with 11 additions and 4 deletions

View file

@ -50,6 +50,12 @@ class NotAuthorizedError extends OError {
}
}
class NotJoinedError extends OError {
constructor() {
super('no project_id found on client')
}
}
class NullBytesInOpError extends OError {
constructor(jsonChange) {
super('null bytes found in op', { jsonChange })
@ -76,6 +82,7 @@ module.exports = {
DocumentUpdaterRequestFailedError,
MissingSessionError,
NotAuthorizedError,
NotJoinedError,
NullBytesInOpError,
UpdateTooLargeError,
WebApiRequestFailedError

View file

@ -9,7 +9,7 @@ const DocumentUpdaterManager = require('./DocumentUpdaterManager')
const ConnectedUsersManager = require('./ConnectedUsersManager')
const WebsocketLoadBalancer = require('./WebsocketLoadBalancer')
const RoomManager = require('./RoomManager')
const { NotAuthorizedError } = require('./Errors')
const { NotAuthorizedError, NotJoinedError } = require('./Errors')
let WebsocketController
module.exports = WebsocketController = {
@ -158,7 +158,7 @@ module.exports = WebsocketController = {
metrics.inc('editor.join-doc')
const { project_id, user_id, is_restricted_user } = client.ol_context
if (!project_id) {
return callback(new Error('no project_id found on client'))
return callback(new NotJoinedError())
}
logger.log(
{ user_id, project_id, doc_id, fromVersion, client_id: client.id },
@ -424,7 +424,7 @@ module.exports = WebsocketController = {
return callback(null, [])
}
if (!project_id) {
return callback(new Error('no project_id found on client'))
return callback(new NotJoinedError())
}
logger.log(
{ user_id, project_id, client_id: client.id },
@ -459,7 +459,7 @@ module.exports = WebsocketController = {
// client may have disconnected, but we can submit their update to doc-updater anyways.
const { user_id, project_id } = client.ol_context
if (!project_id) {
return callback(new Error('no project_id found on client'))
return callback(new NotJoinedError())
}
WebsocketController._assertClientCanApplyUpdate(