2019-07-19 05:39:58 -04:00
|
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
|
|
|
|
// Error class for legacy errors so they inherit OError while staying
|
|
|
|
// backward-compatible (can be instantiated with string as argument instead
|
|
|
|
// of object)
|
|
|
|
class BackwardCompatibleError extends OError {
|
|
|
|
constructor(messageOrOptions) {
|
|
|
|
let options
|
|
|
|
if (typeof messageOrOptions === 'string') {
|
|
|
|
options = { message: messageOrOptions }
|
|
|
|
} else if (!messageOrOptions) {
|
|
|
|
options = {}
|
|
|
|
} else {
|
|
|
|
options = messageOrOptions
|
|
|
|
}
|
|
|
|
super(options)
|
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class NotFoundError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class ForbiddenError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class ServiceNotConfiguredError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class TooManyRequestsError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class InvalidNameError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class UnsupportedFileTypeError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class UnsupportedExportRecordsError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class V1HistoryNotSyncedError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class ProjectHistoryDisabledError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class V1ConnectionError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class UnconfirmedEmailError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-31 04:22:31 -04:00
|
|
|
class EmailExistsError extends OError {
|
|
|
|
constructor(options) {
|
|
|
|
super({
|
|
|
|
message: 'Email already exists',
|
|
|
|
...options
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class InvalidError extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class NotInV2Error extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class SLInV2Error extends BackwardCompatibleError {}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-09-12 10:01:12 -04:00
|
|
|
class SAMLIdentityExistsError extends BackwardCompatibleError {
|
|
|
|
constructor(arg) {
|
|
|
|
super(arg)
|
|
|
|
if (!this.message) {
|
|
|
|
this.message =
|
|
|
|
'provider and external id already linked to another account'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-27 16:48:00 -04:00
|
|
|
class SAMLUserNotFoundError extends BackwardCompatibleError {
|
|
|
|
constructor(arg) {
|
|
|
|
super(arg)
|
|
|
|
if (!this.message) {
|
|
|
|
this.message = 'user not found for SAML provider and external id'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class ThirdPartyIdentityExistsError extends BackwardCompatibleError {
|
|
|
|
constructor(arg) {
|
|
|
|
super(arg)
|
|
|
|
if (!this.message) {
|
|
|
|
this.message =
|
|
|
|
'provider and external id already linked to another account'
|
|
|
|
}
|
2019-07-01 18:11:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
class ThirdPartyUserNotFoundError extends BackwardCompatibleError {
|
|
|
|
constructor(arg) {
|
|
|
|
super(arg)
|
|
|
|
if (!this.message) {
|
|
|
|
this.message = 'user not found for provider and external id'
|
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 05:40:23 -04:00
|
|
|
class SubscriptionAdminDeletionError extends OError {
|
|
|
|
constructor(options) {
|
|
|
|
super({
|
|
|
|
message: 'subscription admins cannot be deleted',
|
|
|
|
...options
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 05:39:58 -04:00
|
|
|
module.exports = {
|
|
|
|
OError,
|
|
|
|
BackwardCompatibleError,
|
2019-05-29 05:21:06 -04:00
|
|
|
NotFoundError,
|
|
|
|
ForbiddenError,
|
|
|
|
ServiceNotConfiguredError,
|
|
|
|
TooManyRequestsError,
|
|
|
|
InvalidNameError,
|
|
|
|
UnsupportedFileTypeError,
|
|
|
|
UnsupportedExportRecordsError,
|
|
|
|
V1HistoryNotSyncedError,
|
|
|
|
ProjectHistoryDisabledError,
|
|
|
|
V1ConnectionError,
|
|
|
|
UnconfirmedEmailError,
|
|
|
|
EmailExistsError,
|
|
|
|
InvalidError,
|
|
|
|
NotInV2Error,
|
2019-09-12 10:01:12 -04:00
|
|
|
SAMLIdentityExistsError,
|
2019-08-27 16:48:00 -04:00
|
|
|
SAMLUserNotFoundError,
|
2019-05-29 05:21:06 -04:00
|
|
|
SLInV2Error,
|
2019-07-01 18:11:07 -04:00
|
|
|
ThirdPartyIdentityExistsError,
|
2019-05-29 05:21:06 -04:00
|
|
|
ThirdPartyUserNotFoundError,
|
|
|
|
SubscriptionAdminDeletionError
|
|
|
|
}
|