Concurrency/ToDo Sample not working

蹲街弑〆低调 提交于 2019-12-02 18:07:57

问题


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

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
    }

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

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

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


回答1:


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. 
});



回答2:


Error on my side here... Clicking 'Continue' on the Exception Windows in VS the javascript handler is executed.



来源:https://stackoverflow.com/questions/13855885/concurrency-todo-sample-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!