1 import { c } from 'ttag';
3 export enum VALIDATION_ERROR_TYPES {
5 EXTERNAL_INVITE_DISABLED,
6 EXTERNAL_INVITE_NOT_AVAILABLE,
14 EXTERNAL_INVITE_DISABLED,
15 EXTERNAL_INVITE_NOT_AVAILABLE,
19 } = VALIDATION_ERROR_TYPES;
21 const getValidationErrorMessage = (type: VALIDATION_ERROR_TYPES) => {
22 if (type === INVALID_EMAIL) {
23 return c('Error').t`The address might be misspelled`;
25 if (type === EXTERNAL_INVITE_DISABLED) {
26 return c('Error').t`External invitations are temporarily disabled.`;
28 if (type === EXTERNAL_INVITE_NOT_AVAILABLE) {
29 return c('Error').t`External invitations are not available yet.`;
31 if (type === DOES_NOT_EXIST) {
32 return c('Error').t`Account does not exist`;
34 if (type === EXISTING_MEMBER) {
35 return c('Error').t`Already a member of this share`;
37 if (type === NOT_INTERNAL_ACCOUNT) {
38 return c('Error').t`External accounts are not supported yet`;
40 return c('Error').t`Validation error`;
43 export class ShareInviteeValidationError extends Error {
44 type: VALIDATION_ERROR_TYPES;
46 constructor(type: VALIDATION_ERROR_TYPES) {
47 const message = getValidationErrorMessage(type);
50 Object.setPrototypeOf(this, ShareInviteeValidationError.prototype);