Fixing unhandled exception for microsoft driver (#10223)

Fixing a difficult bug: an unhandled exception for microsoft driver when
one of the many Microsoft BATCH request failed.
This commit is contained in:
Guillim
2025-02-14 18:50:53 +01:00
committed by GitHub
parent 70e5cdfe83
commit bab529b138
3 changed files with 17 additions and 3 deletions

View File

@ -134,7 +134,12 @@ export class MicrosoftGetMessagesService {
return response.body;
}
return { error: response.error };
return {
error: {
...response.body.error,
statusCode: response.status,
},
};
});
}
}

View File

@ -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',

View File

@ -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 =