fix: handle object error messages

This commit is contained in:
yassinedorbozgithub 2025-01-17 11:56:59 +01:00
parent f941fc9ff6
commit 6eb29e9a96
3 changed files with 2 additions and 6 deletions

View File

@ -169,7 +169,6 @@ describe('BlockRepository', () => {
}); });
describe('prepareBlocksInCategoryUpdateScope', () => { describe('prepareBlocksInCategoryUpdateScope', () => {
/******/
it('should update blocks within the scope based on category and ids', async () => { it('should update blocks within the scope based on category and ids', async () => {
jest.spyOn(blockRepository, 'findOne').mockResolvedValue({ jest.spyOn(blockRepository, 'findOne').mockResolvedValue({
id: blockValidIds[0], id: blockValidIds[0],
@ -211,7 +210,6 @@ describe('BlockRepository', () => {
}); });
describe('prepareBlocksOutOfCategoryUpdateScope', () => { describe('prepareBlocksOutOfCategoryUpdateScope', () => {
/******/
it('should update blocks outside the scope by removing references from attachedBlock', async () => { it('should update blocks outside the scope by removing references from attachedBlock', async () => {
const otherBlocks = [ const otherBlocks = [
{ {
@ -233,7 +231,6 @@ describe('BlockRepository', () => {
}); });
}); });
/******/
it('should update blocks outside the scope by removing references from nextBlocks', async () => { it('should update blocks outside the scope by removing references from nextBlocks', async () => {
const otherBlocks = [ const otherBlocks = [
{ {
@ -256,7 +253,6 @@ describe('BlockRepository', () => {
}); });
describe('preUpdateMany', () => { describe('preUpdateMany', () => {
/******/
it('should update blocks in and out of the scope', async () => { it('should update blocks in and out of the scope', async () => {
const mockFind = jest.spyOn(blockRepository, 'find').mockResolvedValue([ const mockFind = jest.spyOn(blockRepository, 'find').mockResolvedValue([
{ {

View File

@ -515,7 +515,7 @@ export abstract class BaseRepository<
const result = await this.executeOne(query, this.cls); const result = await this.executeOne(query, this.cls);
if (!result) { 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); throw new Error(errorMessage);
} }

View File

@ -7,4 +7,4 @@
*/ */
export const getUpdateOneError = (entity: string, id?: string) => 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}\"` : ''}`);