diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.ts index 15355859b9..02013355ca 100644 --- a/packages/twenty-server/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.ts +++ b/packages/twenty-server/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.ts @@ -50,10 +50,6 @@ export class MessageImportExceptionHandlerService { }; } - this.exceptionHandlerService.captureExceptions([exception], { - workspace: { id: workspaceId }, - }); - if ('code' in exception) { switch (exception.code) { case MessageImportDriverExceptionCode.NOT_FOUND: @@ -90,11 +86,15 @@ export class MessageImportExceptionHandlerService { case MessageImportDriverExceptionCode.UNKNOWN: case MessageImportDriverExceptionCode.UNKNOWN_NETWORK_ERROR: default: - await this.handleUnknownException(messageChannel, workspaceId); + await this.handleUnknownException( + exception, + messageChannel, + workspaceId, + ); break; } } else { - await this.handleUnknownException(messageChannel, workspaceId); + await this.handleUnknownException(exception, messageChannel, workspaceId); } } @@ -177,9 +177,13 @@ export class MessageImportExceptionHandlerService { } private async handleUnknownException( + exception: Error, messageChannel: Pick, workspaceId: string, ): Promise { + this.exceptionHandlerService.captureExceptions([exception], { + workspace: { id: workspaceId }, + }); await this.messageChannelSyncStatusService.markAsFailed( [messageChannel.id], workspaceId,