2020-08-20 09:41:16 +00:00
|
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
|
2020-08-20 11:59:52 +00:00
|
|
|
class ClientRequestedMissingOpsError extends OError {
|
|
|
|
constructor(statusCode) {
|
|
|
|
super('doc updater could not load requested ops', {
|
2021-07-13 11:04:45 +00:00
|
|
|
statusCode,
|
2020-08-20 11:59:52 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 09:41:16 +00:00
|
|
|
class CodedError extends OError {
|
2020-07-07 10:06:02 +00:00
|
|
|
constructor(message, code) {
|
2020-08-20 09:41:16 +00:00
|
|
|
super(message, { code })
|
2020-07-07 10:06:02 +00:00
|
|
|
}
|
2020-06-23 17:29:44 +00:00
|
|
|
}
|
2019-08-31 13:04:36 +00:00
|
|
|
|
2020-08-20 11:14:02 +00:00
|
|
|
class CorruptedJoinProjectResponseError extends OError {
|
|
|
|
constructor() {
|
|
|
|
super('no data returned from joinProject request')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:03:34 +00:00
|
|
|
class DataTooLargeToParseError extends OError {
|
|
|
|
constructor(data) {
|
|
|
|
super('data too large to parse', {
|
|
|
|
head: data.slice(0, 1024),
|
2021-07-13 11:04:45 +00:00
|
|
|
length: data.length,
|
2020-08-20 10:03:34 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 11:52:59 +00:00
|
|
|
class DocumentUpdaterRequestFailedError extends OError {
|
|
|
|
constructor(action, statusCode) {
|
|
|
|
super('doc updater returned a non-success status code', {
|
|
|
|
action,
|
2021-07-13 11:04:45 +00:00
|
|
|
statusCode,
|
2020-08-20 11:52:59 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 12:10:22 +00:00
|
|
|
class JoinLeaveEpochMismatchError extends OError {
|
|
|
|
constructor() {
|
|
|
|
super('joinLeaveEpoch mismatch')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:38:10 +00:00
|
|
|
class MissingSessionError extends OError {
|
|
|
|
constructor() {
|
|
|
|
super('could not look up session by key')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:50:35 +00:00
|
|
|
class NotAuthorizedError extends OError {
|
|
|
|
constructor() {
|
|
|
|
super('not authorized')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 12:07:27 +00:00
|
|
|
class NotJoinedError extends OError {
|
|
|
|
constructor() {
|
|
|
|
super('no project_id found on client')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:30:22 +00:00
|
|
|
class NullBytesInOpError extends OError {
|
|
|
|
constructor(jsonChange) {
|
|
|
|
super('null bytes found in op', { jsonChange })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 12:12:56 +00:00
|
|
|
class UnexpectedArgumentsError extends OError {
|
|
|
|
constructor() {
|
|
|
|
super('unexpected arguments')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:16:26 +00:00
|
|
|
class UpdateTooLargeError extends OError {
|
|
|
|
constructor(updateSize) {
|
|
|
|
super('update is too large', { updateSize })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 11:03:54 +00:00
|
|
|
class WebApiRequestFailedError extends OError {
|
|
|
|
constructor(statusCode) {
|
|
|
|
super('non-success status code from web', { statusCode })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:30:22 +00:00
|
|
|
module.exports = {
|
|
|
|
CodedError,
|
2020-08-20 11:14:02 +00:00
|
|
|
CorruptedJoinProjectResponseError,
|
2020-08-20 11:59:52 +00:00
|
|
|
ClientRequestedMissingOpsError,
|
2020-08-20 10:30:22 +00:00
|
|
|
DataTooLargeToParseError,
|
2020-08-20 11:52:59 +00:00
|
|
|
DocumentUpdaterRequestFailedError,
|
2020-08-20 12:10:22 +00:00
|
|
|
JoinLeaveEpochMismatchError,
|
2020-08-20 10:38:10 +00:00
|
|
|
MissingSessionError,
|
2020-08-20 10:50:35 +00:00
|
|
|
NotAuthorizedError,
|
2020-08-20 12:07:27 +00:00
|
|
|
NotJoinedError,
|
2020-08-20 10:30:22 +00:00
|
|
|
NullBytesInOpError,
|
2020-08-20 12:12:56 +00:00
|
|
|
UnexpectedArgumentsError,
|
2020-08-20 11:03:54 +00:00
|
|
|
UpdateTooLargeError,
|
2021-07-13 11:04:45 +00:00
|
|
|
WebApiRequestFailedError,
|
2020-08-20 10:30:22 +00:00
|
|
|
}
|