Skip to content

The open alternative to Salesforce, designed for AI.

handle HTTP 400, 500, 502, 504 in parseMicrosoftMessagesImportError (#17509)

neo773945bedb7c789
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/utils/parse-microsoft-messages-import.util.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/utils/parse-microsoft-messages-import.util.ts
index 5c8160dba1c..b61c494215f 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/utils/parse-microsoft-messages-import.util.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/utils/parse-microsoft-messages-import.util.ts
@@ -11,6 +11,14 @@ export const parseMicrosoftMessagesImportError = (
},
options?: { cause?: Error },
): MessageImportDriverException => {
+ if (error.statusCode === 400) {
+ return new MessageImportDriverException(
+ `Invalid request to Microsoft Graph API: ${error.message}`,
+ MessageImportDriverExceptionCode.UNKNOWN,
+ { cause: options?.cause },
+ );
+ }
+
if (error.statusCode === 401) {
return new MessageImportDriverException(
'Unauthorized access to Microsoft Graph API',
@@ -47,9 +55,20 @@ export const parseMicrosoftMessagesImportError = (
}
}
+ if (error.statusCode === 410) {
+ return new MessageImportDriverException(
+ `Sync cursor error: ${error.message}`,
+ MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,
+ { cause: options?.cause },
+ );
+ }
+
if (
error.statusCode === 429 ||
+ error.statusCode === 500 ||
+ error.statusCode === 502 ||
error.statusCode === 503 ||
+ error.statusCode === 504 ||
error.statusCode === 509
) {
return new MessageImportDriverException(
@@ -59,14 +78,6 @@ export const parseMicrosoftMessagesImportError = (
);
}
- if (error.statusCode === 410) {
- return new MessageImportDriverException(
- `Sync cursor error: ${error.message}`,
- MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,
- { cause: options?.cause },
- );
- }
-
return new MessageImportDriverException(
`Microsoft Graph API unknown error: ${error} with status code ${error.statusCode}`,
MessageImportDriverExceptionCode.UNKNOWN,