I have pasted a callback below that is in my waterline model
In order to give the client a pretty message I'm attempting to modify the status of the error object so that res.negotiate(err) will respond with badRequest. But my error.status = 400 seems to be ignored and when its passed to res.negotiate I still get 500 error returned (server error instead of bad request).
I'm working off of these docs
http://sailsjs.org/#/documentation/reference/res/res.negotiate.html https://docs.nodejitsu.com/articles/errors/what-is-the-error-object http://massalabs.com/dev/2013/10/17/handling-errors-in-nodejs.html
Thoughts, bug?
beforeDestroy: function(criteria, next){
var error = new Error('This shift has people scheduled and can not be deleted.');
error.type = 'user';
error.status = 400;
return next(error);
}
Also, even when I get a Server Error returned the message. In this case "This shift has people scheduled ..." can not be found on the error object that is returned? I'm using the unmodified response pages and I don't know why its being stripped out?
This is the error object being returned to the client.
error: "E_UNKNOWN"
raw: {}
status: 500
summary: "Encountered an unexpected error"