Skip to content

Commit cec9dda

Browse files
committedOct 13, 2019
Minor refactor to ValidationError
1 parent 13ae085 commit cec9dda

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎lib/error/validation.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,23 @@ const util = require('util');
1717

1818
function ValidationError(instance) {
1919
this.errors = {};
20+
this.name = 'ValidationError';
2021
this._message = '';
22+
2123
if (instance && instance.constructor.name === 'model') {
2224
this._message = instance.constructor.modelName + ' validation failed';
23-
MongooseError.call(this, this._message);
2425
} else {
2526
this._message = 'Validation failed';
26-
MongooseError.call(this, this._message);
2727
}
28-
this.name = 'ValidationError';
28+
29+
MongooseError.call(this, this._message);
30+
2931
if (Error.captureStackTrace) {
3032
Error.captureStackTrace(this);
3133
} else {
3234
this.stack = new Error().stack;
3335
}
36+
3437
if (instance) {
3538
instance.errors = this.errors;
3639
}

0 commit comments

Comments
 (0)
Please sign in to comment.