You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
860 B
JavaScript
42 lines
860 B
JavaScript
11 months ago
|
/*!
|
||
|
* Module dependencies.
|
||
|
*/
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
const MongooseError = require('./');
|
||
|
|
||
|
|
||
|
/**
|
||
|
* If `eachAsync()` is called with `continueOnError: true`, there can be
|
||
|
* multiple errors. This error class contains an `errors` property, which
|
||
|
* contains an array of all errors that occurred in `eachAsync()`.
|
||
|
*
|
||
|
* @api private
|
||
|
*/
|
||
|
|
||
|
class EachAsyncMultiError extends MongooseError {
|
||
|
/**
|
||
|
* @param {String} connectionString
|
||
|
*/
|
||
|
constructor(errors) {
|
||
|
let preview = errors.map(e => e.message).join(', ');
|
||
|
if (preview.length > 50) {
|
||
|
preview = preview.slice(0, 50) + '...';
|
||
|
}
|
||
|
super(`eachAsync() finished with ${errors.length} errors: ${preview}`);
|
||
|
|
||
|
this.errors = errors;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Object.defineProperty(EachAsyncMultiError.prototype, 'name', {
|
||
|
value: 'EachAsyncMultiError'
|
||
|
});
|
||
|
|
||
|
/*!
|
||
|
* exports
|
||
|
*/
|
||
|
|
||
|
module.exports = EachAsyncMultiError;
|