2015-10-28 16 views
0

的錯誤,當我運行下面的代碼 -捕獲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代碼中捕獲此錯誤並向用戶顯示消息?

謝謝

回答

0

是的。只是將它們包裹在試塊中 -

try { 

} 
Catch(error) 
{ 

}