overleaf/services/web/app/src/Features/Errors/Errors.js
Eric Mc Sween 3ec74ac6f2 Merge pull request #2164 from overleaf/em-ownership-transfer
Project ownership transfer backend endpoint

GitOrigin-RevId: b7d267f2c105e8f51d5013289ac4afeb077c1e21
2019-09-30 15:01:03 +00:00

168 lines
3.9 KiB
JavaScript

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)
}
}
class NotFoundError extends BackwardCompatibleError {}
class ForbiddenError extends BackwardCompatibleError {}
class ServiceNotConfiguredError extends BackwardCompatibleError {}
class TooManyRequestsError extends BackwardCompatibleError {}
class InvalidNameError extends BackwardCompatibleError {}
class UnsupportedFileTypeError extends BackwardCompatibleError {}
class UnsupportedExportRecordsError extends BackwardCompatibleError {}
class V1HistoryNotSyncedError extends BackwardCompatibleError {}
class ProjectHistoryDisabledError extends BackwardCompatibleError {}
class V1ConnectionError extends BackwardCompatibleError {}
class UnconfirmedEmailError extends BackwardCompatibleError {}
class EmailExistsError extends OError {
constructor(options) {
super({
message: 'Email already exists',
...options
})
}
}
class InvalidError extends BackwardCompatibleError {}
class NotInV2Error extends BackwardCompatibleError {}
class SLInV2Error extends BackwardCompatibleError {}
class SAMLIdentityExistsError extends BackwardCompatibleError {
constructor(arg) {
super(arg)
if (!this.message) {
this.message =
'provider and external id already linked to another account'
}
}
}
class SAMLSessionDataMissing extends BackwardCompatibleError {
constructor(arg) {
super(arg)
if (!this.message) {
this.message =
'Please resubmit your institutional email.<br/><a href="/institutional-login">institutional login</a>'
}
}
}
class SAMLUserNotFoundError extends BackwardCompatibleError {
constructor(arg) {
super(arg)
if (!this.message) {
this.message = 'user not found for SAML provider and external id'
}
}
}
class ThirdPartyIdentityExistsError extends BackwardCompatibleError {
constructor(arg) {
super(arg)
if (!this.message) {
this.message =
'provider and external id already linked to another account'
}
}
}
class ThirdPartyUserNotFoundError extends BackwardCompatibleError {
constructor(arg) {
super(arg)
if (!this.message) {
this.message = 'user not found for provider and external id'
}
}
}
class SubscriptionAdminDeletionError extends OError {
constructor(options) {
super({
message: 'subscription admins cannot be deleted',
...options
})
}
}
class ProjectNotFoundError extends OError {
constructor(options) {
super({
message: 'project not found',
...options
})
}
}
class UserNotFoundError extends OError {
constructor(options) {
super({
message: 'user not found',
...options
})
}
}
class UserNotCollaboratorError extends OError {
constructor(options) {
super({
message: 'user not a collaborator',
...options
})
}
}
module.exports = {
OError,
BackwardCompatibleError,
NotFoundError,
ForbiddenError,
ServiceNotConfiguredError,
TooManyRequestsError,
InvalidNameError,
UnsupportedFileTypeError,
UnsupportedExportRecordsError,
V1HistoryNotSyncedError,
ProjectHistoryDisabledError,
V1ConnectionError,
UnconfirmedEmailError,
EmailExistsError,
InvalidError,
NotInV2Error,
SAMLIdentityExistsError,
SAMLSessionDataMissing,
SAMLUserNotFoundError,
SLInV2Error,
ThirdPartyIdentityExistsError,
ThirdPartyUserNotFoundError,
SubscriptionAdminDeletionError,
ProjectNotFoundError,
UserNotFoundError,
UserNotCollaboratorError
}