Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Problem with the error handler on update error #20

Closed
nicogranelli opened this Issue · 6 comments

3 participants

@nicogranelli

I'm using this project for the first time. This are the steps to reproduce the error:

1) fetch a model
2) change the model in futon (to trigger an error for conflict)
3) save the model
4) the error callback is called, but with wrong arguments. I used a console.log(arguments) inside the callback, and I get these 3:

  • The model
  • undefined
  • and Object with success and error, both functions

According to http://documentcloud.github.com/backbone/#Model-save, the error callback should get the model and the response.

NOTE: Maybe this is because couchdb, and response can't be returned, I'm not sure, I don't know this project or couchdb well enough to be sure.

@nicogranelli

PD: Do you need an unit test showing the error? I can try to write a jasmine showing it

@janmonschke
Owner

That would be handy!

@mikeymckay

I'm having the same problem. How do I get access to the actual error that was thrown during a save() ?

@janmonschke
Owner

Digging into it right now

@janmonschke
Owner

Unfortunately there's no way to access the response itself since jquery.couch.js does not pass it to the error-callback. But I added a new object that will be passed to error-callbacks that accumulates at least some information on the request.

A simple example for an error callback for a non-existing model:

myModel.fetch({error: function(model, req, options){
    console.log(model, req, options);
}});

This would lead to the following console output:

Screenshot

Is this sufficient enough?

@nicogranelli

sorry for the late response, I always miss github notifications.

Backbone return the response so the user could check the error, so returning the error instead is pretty close.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.