Skip to content

The open alternative to Salesforce, designed for AI.

replace log by throw (#10167)

martmullb66289c44c30
diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts
index f5280c89d24..9d28f044fcb 100644
--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts
@@ -14,5 +14,6 @@ export enum ServerlessFunctionExceptionCode {
SERVERLESS_FUNCTION_ALREADY_EXIST = 'SERVERLESS_FUNCTION_ALREADY_EXIST',
SERVERLESS_FUNCTION_NOT_READY = 'SERVERLESS_FUNCTION_NOT_READY',
SERVERLESS_FUNCTION_BUILDING = 'SERVERLESS_FUNCTION_BUILDING',
+ SERVERLESS_FUNCTION_CODE_UNCHANGED = 'SERVERLESS_FUNCTION_CODE_UNCHANGED',
SERVERLESS_FUNCTION_EXECUTION_LIMIT_REACHED = 'SERVERLESS_FUNCTION_EXECUTION_LIMIT_REACHED',
}
diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts
index c86ab312252..58daac69159 100644
--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts
@@ -193,8 +193,9 @@ export class ServerlessFunctionService {
);
if (deepEqual(latestCode, draftCode)) {
- throw new Error(
+ throw new ServerlessFunctionException(
'Cannot publish a new version when code has not changed',
+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_CODE_UNCHANGED,
);
}
}
diff --git a/packages/twenty-server/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.ts b/packages/twenty-server/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.ts
index 3bf3dc31ba0..e5897f9b5bd 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.ts
@@ -20,6 +20,7 @@ import {
import { getStatusCombinationFromArray } from 'src/modules/workflow/workflow-status/utils/get-status-combination-from-array.util';
import { getStatusCombinationFromUpdate } from 'src/modules/workflow/workflow-status/utils/get-status-combination-from-update.util';
import { getWorkflowStatusesFromCombination } from 'src/modules/workflow/workflow-status/utils/get-statuses-from-combination.util';
+import { ServerlessFunctionExceptionCode } from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';
export enum WorkflowVersionEventType {
CREATE = 'CREATE',
@@ -174,9 +175,14 @@ export class WorkflowStatusesUpdateJob {
// applied between draft and lastPublished version.
// If no change have been applied, we just use the same
// serverless function version
- this.logger.warn(
- `Error while publishing serverless function '${step.settings.input.serverlessFunctionId}': ${e}`,
- );
+ if (
+ e.code !==
+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_CODE_UNCHANGED
+ ) {
+ this.logger.error(
+ `Error while publishing serverless function '${step.settings.input.serverlessFunctionId}': ${e}`,
+ );
+ }
}
const serverlessFunction =