不要怂,就是干,撸起袖子干!

Changed logic in ValidationError, message is now used if provided. Tests are now passing.

1 parent 62e0330a
Showing with 9 additions and 3 deletions
...@@ -40,11 +40,17 @@ util.inherits(error.BaseError, Error); ...@@ -40,11 +40,17 @@ util.inherits(error.BaseError, Error);
error.ValidationError = function(message, errors) { error.ValidationError = function(message, errors) {
error.BaseError.apply(this, arguments); error.BaseError.apply(this, arguments);
this.name = 'SequelizeValidationError'; this.name = 'SequelizeValidationError';
this.message = 'Validation Error';
this.errors = errors || []; this.errors = errors || [];
if (this.errors.length > 0 && this.errors[0].message) { // Use provided error message if available...
this.message = this.errors.map(function (err) { if (message) {
return err.type + ": " + err.message; this.message = message;
// ... otherwise create a concatenated message out of existing errors.
} else if (this.errors.length > 0 && this.errors[0].message) {
this.message = this.errors.map(function(err) {
return err.type + ': ' + err.message;
}).join(',\n'); }).join(',\n');
} }
}; };
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!