2014-07-17 25 views
0

如下圖所示,關於併發異常,saveChanges失敗函數在錯誤obj中給我沒有詳細prop。Breezejs SaveChanges error.detail未定義爲OptimisticConcurrencyException

搜索後,發現我需要設置客戶關閉在網絡config.however但在prod服務器或本地主機沒有可用的方式來獲取細節道具。 當我深入到錯誤道具,我發現內部異常的內部異常併發異常,但錯誤obj的詳細屬性仍未定義。

請讓我知道我缺少的一點。

IM使用MVC應用程序與webapi2與vs2013

enter image description here

回答

0

你能確保你的實體所需的屬性都被設置,尤其是ID或任何外鍵字段?

這聽起來像是一個實體框架錯誤被拋出應該在你的屏幕截圖中的httpResponse對象,但更好的解決方案是調試服務器,看看是什麼造成它。

您可以檢查您的保存有效負載的問題或設置服務器上的斷點進一步檢查。

0

我試着去saveChanges的saveError方法中測試下面的代碼。我試過的只是在瀏覽器的不同選項卡中打開同一個實體並刪除兩者。第二次刪除實際上給了我System.Exception在innerexception中有併發異常的服務器。但是細節prop是不確定的。

var reason = error.message; 
     var detail = error.detail; 

     if (error.entityErrors) { 
      reason = this.handleSaveValidationError(error); 
     } else if (detail && detail.ExceptionType && 
      detail.ExceptionType.indexOf('OptimisticConcurrencyException') !== -1) { 
      // Concurrency error 
      reason = 
       "Another user, perhaps the server, " + 
       "may have deleted one or all of the todos." + 
       " You may have to restart the app."; 
     } else { 
      reason = "Failed to save changes: " + reason + 
       " You may have to restart the app."; 
     } 

這是我從服務器獲取的SaveChanges後的反應

enter image description here

相關問題