mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
fix: handle object error messages
This commit is contained in:
parent
f941fc9ff6
commit
6eb29e9a96
@ -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([
|
||||||
{
|
{
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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}\"` : ''}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user