Skip to content

The open alternative to Salesforce, designed for AI.

Fixing unhandled exception for microsoft driver (#10223)

Guillimbab529b1382f
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-messages.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-messages.service.ts
index b9a0bd0efd7..3bb7c301d9b 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-messages.service.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-messages.service.ts
@@ -134,7 +134,12 @@ export class MicrosoftGetMessagesService {
return response.body;
}
- return { error: response.error };
+ return {
+ error: {
+ ...response.body.error,
+ statusCode: response.status,
+ },
+ };
});
}
}
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-handle-error.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-handle-error.service.ts
index 5c7560c425b..0659e2e0231 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-handle-error.service.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-handle-error.service.ts
@@ -10,6 +10,13 @@ import {
@Injectable()
export class MicrosoftHandleErrorService {
public handleMicrosoftMessageFetchError(error: GraphError): void {
+ if (!error.statusCode) {
+ throw new MessageImportDriverException(
+ `Microsoft Graph API unknown error: ${error}`,
+ MessageImportDriverExceptionCode.UNKNOWN,
+ );
+ }
+
if (error.statusCode === 401) {
throw new MessageImportDriverException(
'Unauthorized access to Microsoft Graph API',
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/services/message-import-exception-handler.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/services/message-import-exception-handler.service.ts
index faaccee96e4..d942e8f2baa 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/services/message-import-exception-handler.service.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/services/message-import-exception-handler.service.ts
@@ -91,8 +91,10 @@ export class MessageImportExceptionHandlerService {
[messageChannel.id],
workspaceId,
);
-
- return;
+ throw new MessageImportException(
+ `Unknown error occurred multiple times while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}`,
+ MessageImportExceptionCode.UNKNOWN,
+ );
}
const messageChannelRepository =