There seems to be something wrong in the error handling for posting a new document:
AngularBridge.prototype.collectionPost = function() {
return _.bind(function(req, res, next) {
if (!req.resource) { next(); return; }
var self = this;
if (!req.body) throw new Error('Nothing submitted.');
var epured_body = this.epureRequest(req, req.resource);
var doc = new req.resource.model(epured_body);
doc.save(function(err) {
if (err) { error(err); return; } // <-- error not defined
if(doc.schema.methods.post) doc.schema.methods.post();
res.send(doc);
});
}, this);
};
The error handling seems to be a little inconsistent through out the library. Some places an exception is thrown, others uses the response object to send an error object. Some places the actual error is returned, in other places only success = false is sent.
And as far as I can see, all errors are returned with an 200 OK status. Is that right?
Angular-bridge looks really interesting.
There seems to be something wrong in the error handling for posting a new document:
The error handling seems to be a little inconsistent through out the library. Some places an exception is thrown, others uses the response object to send an error object. Some places the actual error is returned, in other places only success = false is sent.
And as far as I can see, all errors are returned with an 200 OK status. Is that right?