Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the error handler on update error #20

Closed
nicogranelli opened this issue Oct 14, 2011 · 6 comments
Closed

Problem with the error handler on update error #20

nicogranelli opened this issue Oct 14, 2011 · 6 comments

Comments

@nicogranelli
Copy link

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
Copy link
Author

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

@janmonschke
Copy link
Owner

That would be handy!

@mikeymckay
Copy link
Contributor

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

@janmonschke
Copy link
Owner

Digging into it right now

@janmonschke
Copy link
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
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants