-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13420 from Automattic/7.2
7.2
- Loading branch information
Showing
23 changed files
with
566 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*! | ||
* Module dependencies. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const MongooseError = require('./'); | ||
|
||
|
||
/** | ||
* If `bulkWrite()` or `insertMany()` has validation errors, but | ||
* all valid operations succeed, and 'throwOnValidationError' is true, | ||
* Mongoose will throw this error. | ||
* | ||
* @api private | ||
*/ | ||
|
||
class MongooseBulkWriteError extends MongooseError { | ||
constructor(validationErrors, results, rawResult, operation) { | ||
let preview = validationErrors.map(e => e.message).join(', '); | ||
if (preview.length > 200) { | ||
preview = preview.slice(0, 200) + '...'; | ||
} | ||
super(`${operation} failed with ${validationErrors.length} Mongoose validation errors: ${preview}`); | ||
|
||
this.validationErrors = validationErrors; | ||
this.results = results; | ||
this.rawResult = rawResult; | ||
this.operation = operation; | ||
} | ||
} | ||
|
||
Object.defineProperty(MongooseBulkWriteError.prototype, 'name', { | ||
value: 'MongooseBulkWriteError' | ||
}); | ||
|
||
/*! | ||
* exports | ||
*/ | ||
|
||
module.exports = MongooseBulkWriteError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
/*! | ||
* Module dependencies. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const MongooseError = require('./'); | ||
|
||
class InvalidSchemaOptionError extends MongooseError { | ||
/** | ||
* InvalidSchemaOption Error constructor. | ||
* @param {String} name | ||
* @api private | ||
*/ | ||
constructor(name, option) { | ||
const msg = `Cannot create use schema for property "${name}" because the schema has the ${option} option enabled.`; | ||
super(msg); | ||
} | ||
} | ||
|
||
Object.defineProperty(InvalidSchemaOptionError.prototype, 'name', { | ||
value: 'InvalidSchemaOptionError' | ||
}); | ||
|
||
/*! | ||
* exports | ||
*/ | ||
|
||
module.exports = InvalidSchemaOptionError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.