Skip to content

Commit d9163f5

Browse files
authored
fix: correct order for declaration
1 parent cec9dda commit d9163f5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/error/validation.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ const util = require('util');
1717

1818
function ValidationError(instance) {
1919
this.errors = {};
20-
this.name = 'ValidationError';
2120
this._message = '';
2221

22+
MongooseError.call(this, this._message);
2323
if (instance && instance.constructor.name === 'model') {
2424
this._message = instance.constructor.modelName + ' validation failed';
2525
} else {
2626
this._message = 'Validation failed';
2727
}
28-
29-
MongooseError.call(this, this._message);
28+
this.name = 'ValidationError';
3029

3130
if (Error.captureStackTrace) {
3231
Error.captureStackTrace(this);

0 commit comments

Comments
 (0)