Skip to content

Instantly share code, notes, and snippets.

@michaelvobrien
Created October 18, 2012 10:06
Show Gist options
  • Save michaelvobrien/3910851 to your computer and use it in GitHub Desktop.
Save michaelvobrien/3910851 to your computer and use it in GitHub Desktop.
ember data error handling questions

Questions about Ember Data Error Handling

ember-data.js:https://github.com/emberjs/data/tree/0396411e39df96c8506de3182c81414c1d0eb981

In short, when there is an error, I want to display error messages in the view, and then the user can 1) cancel, which will rollback the transaction 2) correct the input errors and successfully commit the transaction, passing the validations on the server.

Where is the error callback?

  updateRecord: function(store, type, record) {
    var id = get(record, 'id');
    var root = this.rootForType(type);

    var data = {};
    data[root] = this.toJSON(record);

    this.ajax(this.buildURL(root, id), "PUT", {
      data: data,
      context: this,
      success: function(json) {
        this.didUpdateRecord(store, type, record, json);
      }
    });
  },

Overall, what is the flow of receiving an error from the server and updating the view? It seems that an error callback should put the model in an isError state, and then the view can display the appropriate messages. Also, the transaction should stay dirty. That way, the transaction can use rollback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment