From 6eb29e9a96c6a3b250931e39321f7c5f4800439e Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Fri, 17 Jan 2025 11:56:59 +0100 Subject: [PATCH] fix: handle object error messages --- api/src/chat/repositories/block.repository.spec.ts | 4 ---- api/src/utils/generics/base-repository.ts | 2 +- api/src/utils/test/errors/messages.ts | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/api/src/chat/repositories/block.repository.spec.ts b/api/src/chat/repositories/block.repository.spec.ts index 7dc3c5cb..e37d7d62 100644 --- a/api/src/chat/repositories/block.repository.spec.ts +++ b/api/src/chat/repositories/block.repository.spec.ts @@ -169,7 +169,6 @@ describe('BlockRepository', () => { }); describe('prepareBlocksInCategoryUpdateScope', () => { - /******/ it('should update blocks within the scope based on category and ids', async () => { jest.spyOn(blockRepository, 'findOne').mockResolvedValue({ id: blockValidIds[0], @@ -211,7 +210,6 @@ describe('BlockRepository', () => { }); describe('prepareBlocksOutOfCategoryUpdateScope', () => { - /******/ it('should update blocks outside the scope by removing references from attachedBlock', async () => { const otherBlocks = [ { @@ -233,7 +231,6 @@ describe('BlockRepository', () => { }); }); - /******/ it('should update blocks outside the scope by removing references from nextBlocks', async () => { const otherBlocks = [ { @@ -256,7 +253,6 @@ describe('BlockRepository', () => { }); describe('preUpdateMany', () => { - /******/ it('should update blocks in and out of the scope', async () => { const mockFind = jest.spyOn(blockRepository, 'find').mockResolvedValue([ { diff --git a/api/src/utils/generics/base-repository.ts b/api/src/utils/generics/base-repository.ts index 550b6c90..523a42b9 100644 --- a/api/src/utils/generics/base-repository.ts +++ b/api/src/utils/generics/base-repository.ts @@ -515,7 +515,7 @@ export abstract class BaseRepository< const result = await this.executeOne(query, this.cls); if (!result) { - const errorMessage = `Unable to update ${this.cls.name}${typeof criteria === 'string' ? ` with ID ${criteria}` : ''}`; + const errorMessage = `Unable to update ${this.cls.name} with ${typeof criteria === 'string' ? 'ID' : 'criteria'} ${JSON.stringify(criteria)}`; throw new Error(errorMessage); } diff --git a/api/src/utils/test/errors/messages.ts b/api/src/utils/test/errors/messages.ts index 150f1c61..2ecc3aff 100644 --- a/api/src/utils/test/errors/messages.ts +++ b/api/src/utils/test/errors/messages.ts @@ -7,4 +7,4 @@ */ export const getUpdateOneError = (entity: string, id?: string) => - new Error(`Unable to update ${entity}${id ? ` with ID ${id}` : ''}`); + new Error(`Unable to update ${entity}${id ? ` with ID \"${id}\"` : ''}`);