并发/待办事项示例无效

时间:2012-12-13 08:33:58

标签: breeze

我正在尝试使用ToDo示例并在尝试并发处理时遇到未处理的Excaption。

dataservice.js在saveFailed(error)方法中包含这些行:

if (detail && detail.ExceptionType.indexOf('OptimisticConcurrencyException') !== -1) {
        // Concurrency error 
        reason =
            "Another user, perhaps the server, may have deleted one or all of the todos.";
        manager.rejectChanges(); // DEMO ONLY: discard all pending changes
    }

由于:

中未处理的OptimisticConcurrencyException,客户端永远不会到达这一点
[HttpPost]
    public SaveResult SaveChanges(JObject saveBundle) {
        return _contextProvider.SaveChanges(saveBundle);
    }

我试图抓住这个并返回Exception,这是一种愚蠢的行为,因为Exception不是SaveResult类型。这是一个错误还是我错过了某处的配置?

迎接

2 个答案:

答案 0 :(得分:1)

任何服务器端错误都应该返回到promise.fail处理程序。即

em.saveChanges().then(function(saveResult) {
   // normal path

}).fail(function(error) {
   // your concurrency exception message will be part of the error object. 
});

答案 1 :(得分:0)

我这边的错误...在VS的异常窗口上单击“继续”,执行javascript处理程序。

相关问题