1 import { c, msgid } from 'ttag';
3 import { MAX_ATTENDEES } from '@proton/shared/lib/calendar/constants';
5 export enum ADD_EVENT_ERROR_TYPE {
9 const getErrorMessage = (errorType: ADD_EVENT_ERROR_TYPE, maxAttendees = MAX_ATTENDEES) => {
10 if (errorType === ADD_EVENT_ERROR_TYPE.TOO_MANY_PARTICIPANTS) {
11 return c('Error adding participants to a calendar event').ngettext(
12 msgid`At most ${maxAttendees} participant is allowed per invitation`,
13 `At most ${maxAttendees} participants are allowed per invitation`,
20 export class AddAttendeeError extends Error {
21 type: ADD_EVENT_ERROR_TYPE;
23 externalError?: Error;
25 constructor(errorType: ADD_EVENT_ERROR_TYPE, externalError?: Error, maxAttendees?: number) {
26 super(getErrorMessage(errorType, maxAttendees));
27 this.type = errorType;
28 this.externalError = externalError;
29 Object.setPrototypeOf(this, AddAttendeeError.prototype);