【发布时间】:2015-02-23 06:42:01
【问题描述】:
在创建新模型时有什么方法可以处理 500 状态错误,例如
var model = this.store.createRecord('user');
model.save().then(function() {
}, function(error) {
// this callback will not be executed if 500 status response
});
但是,我可以使用模型上的becameError 事件来捕获它,但在这种情况下,错误对象将不可用。
感谢您的回答。
【问题讨论】:
-
我不知道为什么 500 不会回到拒绝钩子,也许我需要创建一个快速模拟来查看它。没有中钩吗?
-
您找到解决方案了吗?我遇到了同样的问题。我也尝试过像这样使用 catch:
javascript var model = this.store.createRecord('user'); model.save().then(function() { }).catch(function(error) { // this callback will not be executed if 500 status response }); -
我发现了我的问题。我在适配器中覆盖了“createMethod”,并且在那里捕获了不允许它们传播到控制器的捕获的错误。
标签: ember.js ember-data