2020-08-20 05:41:16 -04:00
|
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
|
|
|
|
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 06:03:34 -04:00
|
|
|
class DataTooLargeToParseError extends OError {
|
|
|
|
constructor(data) {
|
|
|
|
super('data too large to parse', {
|
|
|
|
head: data.slice(0, 1024),
|
|
|
|
length: data.length
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 06:30:22 -04:00
|
|
|
class NullBytesInOpError extends OError {
|
|
|
|
constructor(jsonChange) {
|
|
|
|
super('null bytes found in op', { jsonChange })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
DataTooLargeToParseError,
|
2020-08-20 06:38:10 -04:00
|
|
|
MissingSessionError,
|
2020-08-20 06:50:35 -04:00
|
|
|
NotAuthorizedError,
|
2020-08-20 06:30:22 -04:00
|
|
|
NullBytesInOpError,
|
2020-08-20 07:03:54 -04:00
|
|
|
UpdateTooLargeError,
|
|
|
|
WebApiRequestFailedError
|
2020-08-20 06:30:22 -04:00
|
|
|
}
|