并发/待办事项示例不起作用 [英] Concurrency/ToDo Sample not working

查看:76
本文介绍了并发/待办事项示例不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行ToDo示例,并在尝试并发处理时遇到未处理的说明。

I was trying out the ToDo sample and ran into an unhandled Excaption while trying out the Concurrency Handling.

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

The dataservice.js contains these lines in saveFailed(error) method:

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:

The client never gets to this point due to an unhandled OptimisticConcurrencyException in:

[HttpPost]
    public SaveResult SaveChanges(JObject saveBundle) {
        return _contextProvider.SaveChanges(saveBundle);
    }

我试图抓住这一点并返回异常,这是一个愚蠢的异常不是 SaveResult 类型。这是错误还是我在某处缺少配置?

I was trying to catch this and return the Exception which was kind of stupid as the Exception is not of type SaveResult. Is this a bug or am i missing an configuration somewhere?

Greets

推荐答案

任何服务器端错误都应返回给promise.fail处理程序。例如

Any server side errors should be returned to the promise.fail handler. i.e.

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

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

这篇关于并发/待办事项示例不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆