简体   繁体   English

如何处理ember-data事务错误?

[英]How to handle ember-data transaction errors?

How do I know when a transaction commit fails? 我怎么知道事务提交何时失败?

var obj = App.store.findAll(App.Todo).get('firstObject');
var t = App.store.transaction();

t.add(obj);
obj.set('summary','New Summary');
t.commit();
// 403 or 401 is returned from the server (request failed)
a.get('isLoading'); // true
a.get('isError'); // false

Use case: I want a user to see that his action (save object) failed. 使用案例:我希望用户看到他的操作(保存对象)失败。

Indeed, as of today, ember-data's RESTAdapter does not process errors on commit requests. 实际上,截至今天,ember-data的RESTAdapter不会在提交请求上处理错误。

You may be interested by the following PR which proposes errors handling support. 您可能对以下提出错误处理支持的PR感兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM