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