From 773f698faf094a293cf5a433ac418a1969bd7522 Mon Sep 17 00:00:00 2001 From: bosiraphael <71827178+bosiraphael@users.noreply.github.com> Date: Thu, 29 Feb 2024 18:11:53 +0100 Subject: [PATCH] Add error handling in GmailPartialSyncService (#4248) * Add error handling in GmailPartialSyncService * improve typing --- .../services/gmail-partial-sync.service.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/workspace/messaging/services/gmail-partial-sync.service.ts b/packages/twenty-server/src/workspace/messaging/services/gmail-partial-sync.service.ts index 889346d4a..fcd7dc771 100644 --- a/packages/twenty-server/src/workspace/messaging/services/gmail-partial-sync.service.ts +++ b/packages/twenty-server/src/workspace/messaging/services/gmail-partial-sync.service.ts @@ -97,6 +97,13 @@ export class GmailPartialSyncService { return; } + if (error) { + throw new Error( + `Error getting history for ${connectedAccountId} in workspace ${workspaceId} during partial-sync: + ${JSON.stringify(error)}`, + ); + } + if (!historyId) { throw new Error( `No historyId found for ${connectedAccountId} in workspace ${workspaceId} during partial-sync`, @@ -254,7 +261,17 @@ export class GmailPartialSyncService { ): Promise<{ history: gmail_v1.Schema$History[]; historyId?: string | null; - error?: any; + error?: { + code: number; + errors: { + domain: string; + reason: string; + message: string; + locationType?: string; + location?: string; + }[]; + message: string; + }; }> { const gmailClient = await this.gmailClientProvider.getGmailClient(refreshToken);