捕获 entity.entityAspect.entityManager.createEntity 的错误

Capturing error of entity.entityAspect.entityManager.createEntity

当我 运行 下面的代码 -

this.entity.entityAspect.entityManager.createEntity('TblReceipt', {

ReceiptNo : 123
....
});

代码 运行 第一次没问题并创建了新实体。现在,当用户再次尝试 运行 时,它会给出以下错误 -

   Uncaught Error: A MergeStrategy of 'Disallowed' does not allow you to attach     an entity when an entity with the same key is already attached"

上述错误出现在控制台中。我如何在 javascript 代码中捕获此错误并向用户显示消息?

谢谢

是的,明白了。只需将它们包装在 try catch 块中 -

try {

}
Catch(error)
{

}