From 1401f800818e772563c7f0a90def9aa15e4c13d9 Mon Sep 17 00:00:00 2001 From: Guillim Date: Thu, 17 Apr 2025 14:16:05 +0200 Subject: [PATCH] Messaging : better logging (#11621) Better error logging for messaging import exception handler. Goal is to have better info on why Unknown errors are thrown and avoid such messages `Unknown error occurred while importing messages for message channel XXXXXXXX in workspace YYYYYYYYYY: Unknown error occurred while importing messages for message channel XXXXXXXX...` --- ...calendar-event-import-exception-handler.service.ts | 11 +++++++++-- .../messaging-import-exception-handler.service.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts index d04b886cf..5baa32038 100644 --- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts +++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common'; +import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service'; import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager'; import { CALENDAR_THROTTLE_MAX_ATTEMPTS } from 'src/modules/calendar/calendar-event-import-manager/constants/calendar-throttle-max-attempts'; import { @@ -12,7 +13,6 @@ import { } from 'src/modules/calendar/calendar-event-import-manager/exceptions/calendar-event-import.exception'; import { CalendarChannelSyncStatusService } from 'src/modules/calendar/common/services/calendar-channel-sync-status.service'; import { CalendarChannelWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity'; - export enum CalendarEventImportSyncStep { FULL_CALENDAR_EVENT_LIST_FETCH = 'FULL_CALENDAR_EVENT_LIST_FETCH', PARTIAL_CALENDAR_EVENT_LIST_FETCH = 'PARTIAL_CALENDAR_EVENT_LIST_FETCH', @@ -24,6 +24,7 @@ export class CalendarEventImportErrorHandlerService { constructor( private readonly twentyORMManager: TwentyORMManager, private readonly calendarChannelSyncStatusService: CalendarChannelSyncStatusService, + private readonly exceptionHandlerService: ExceptionHandlerService, ) {} public async handleDriverException( @@ -147,8 +148,14 @@ export class CalendarEventImportErrorHandlerService { workspaceId, ); + this.exceptionHandlerService.captureExceptions([exception], { + workspace: { + id: workspaceId, + }, + }); + throw new CalendarEventImportException( - `Unknown error occurred while importing calendar events for calendar channel ${calendarChannel.id} in workspace ${workspaceId}: ${exception.message}`, + `Unknown error importing calendar events for calendar channel ${calendarChannel.id} in workspace ${workspaceId}: ${exception.message}`, CalendarEventImportExceptionCode.UNKNOWN, ); } 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 6b04eaee6..497896808 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 @@ -162,11 +162,11 @@ export class MessageImportExceptionHandlerService { ); this.exceptionHandlerService.captureExceptions([ - `Unknown error occurred while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`, + `Unknown error importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`, ]); throw new MessageImportException( - `Unknown error occurred while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`, + exception.message, MessageImportExceptionCode.UNKNOWN, ); }