Different callbacks for error or error as first argument?
- by Florian Margaine
We (and the JS SO chat room) had a talk with @rlemon some days ago about his Little-XHR library about error handling.
Basically, we wanted to decide which error handling pattern should be used:
xhr.get({
// Some parameters, and then
success: function(data) {},
failure: function(data) {}
})
Or:
xhr.get({
// Some parameters, and then
callback: function(err, data) {}
})
One is more jQuery-like, while the other is more Node-like. Some say that the first pattern makes you think more about handling error. I think the opposite, since you may forget the other callback function, while the argument is always there on the second pattern.
Any opinion/advantage/drawback about both these patterns?