mirror of
https://github.com/lingble/twenty.git
synced 2025-10-30 20:27:55 +00:00
https://www.figma.com/design/xt8O9mFeLl46C5InWwoMrN/Twenty?node-id=36235-120877 Did not do the file manager part. A Function is defined using one unique file at the moment Feature protected by featureFlag `IS_FUNCTION_SETTINGS_ENABLED` ## Demo https://github.com/user-attachments/assets/0acb8291-47b4-4521-a6fa-a88b9198609b
28 lines
1007 B
TypeScript
28 lines
1007 B
TypeScript
import {
|
|
ServerlessFunctionException,
|
|
ServerlessFunctionExceptionCode,
|
|
} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';
|
|
import {
|
|
ConflictError,
|
|
ForbiddenError,
|
|
InternalServerError,
|
|
NotFoundError,
|
|
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
|
|
|
export const serverlessFunctionGraphQLApiExceptionHandler = (error: any) => {
|
|
if (error instanceof ServerlessFunctionException) {
|
|
switch (error.code) {
|
|
case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND:
|
|
throw new NotFoundError(error.message);
|
|
case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_ALREADY_EXIST:
|
|
throw new ConflictError(error.message);
|
|
case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_READY:
|
|
case ServerlessFunctionExceptionCode.FEATURE_FLAG_INVALID:
|
|
throw new ForbiddenError(error.message);
|
|
default:
|
|
throw new InternalServerError(error.message);
|
|
}
|
|
}
|
|
throw error;
|
|
};
|