Spaces:
Build error
Build error
File size: 1,991 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 46 47 48 | import { assertUnreachable } from 'twenty-shared/utils';
import {
ConflictError,
ForbiddenError,
NotFoundError,
TimeoutError,
UserInputError,
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
import {
LogicFunctionException,
LogicFunctionExceptionCode,
} from 'src/engine/metadata-modules/logic-function/logic-function.exception';
// oxlint-disable-next-line typescript/no-explicit-any
export const logicFunctionGraphQLApiExceptionHandler = (error: any) => {
if (error instanceof LogicFunctionException) {
switch (error.code) {
case LogicFunctionExceptionCode.LOGIC_FUNCTION_NOT_FOUND:
throw new NotFoundError(error);
case LogicFunctionExceptionCode.LOGIC_FUNCTION_ALREADY_EXIST:
throw new ConflictError(error);
case LogicFunctionExceptionCode.LOGIC_FUNCTION_NOT_READY:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_BUILDING:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_EXECUTION_LIMIT_REACHED:
throw new ForbiddenError(error);
case LogicFunctionExceptionCode.LOGIC_FUNCTION_EXECUTION_TIMEOUT:
throw new TimeoutError(error);
case LogicFunctionExceptionCode.LOGIC_FUNCTION_CODE_UNCHANGED:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_CREATE_FAILED:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_INVALID_SEED_PROJECT:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_PLATFORM_EXECUTION_ERROR:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_LAYER_BUILD_FAILED:
throw error;
case LogicFunctionExceptionCode.LOGIC_FUNCTION_COMPILATION_FAILED:
case LogicFunctionExceptionCode.INVALID_LOGIC_FUNCTION_INPUT:
throw new UserInputError(error);
case LogicFunctionExceptionCode.LOGIC_FUNCTION_DISABLED:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_PREBUILT_BUNDLE_NOT_INSTALLED:
throw new ForbiddenError(error);
default: {
return assertUnreachable(error.code);
}
}
}
throw error;
};
|