Spaces:
Build error
Build error
File size: 1,368 Bytes
d9494a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import { type MessageDescriptor } from '@lingui/core';
import { msg } from '@lingui/core/macro';
import { assertUnreachable } from 'twenty-shared/utils';
import {
appendCommonExceptionCode,
CustomException,
} from 'src/utils/custom-exception';
export const WorkspaceCacheExceptionCode = appendCommonExceptionCode({
MISSING_DECORATOR: 'MISSING_DECORATOR',
INVALID_PARAMETERS: 'INVALID_PARAMETERS',
} as const);
const getWorkspaceCacheExceptionUserFriendlyMessage = (
code: keyof typeof WorkspaceCacheExceptionCode,
) => {
switch (code) {
case WorkspaceCacheExceptionCode.MISSING_DECORATOR:
return msg`Missing decorator configuration.`;
case WorkspaceCacheExceptionCode.INVALID_PARAMETERS:
return msg`Invalid parameters provided.`;
case WorkspaceCacheExceptionCode.INTERNAL_SERVER_ERROR:
return msg`An unexpected error occurred.`;
default:
assertUnreachable(code);
}
};
export class WorkspaceCacheException extends CustomException<
keyof typeof WorkspaceCacheExceptionCode
> {
constructor(
message: string,
code: keyof typeof WorkspaceCacheExceptionCode,
{ userFriendlyMessage }: { userFriendlyMessage?: MessageDescriptor } = {},
) {
super(message, code, {
userFriendlyMessage:
userFriendlyMessage ??
getWorkspaceCacheExceptionUserFriendlyMessage(code),
});
}
}
|