Skip to content

Commit 0b81c6e

Browse files
authored
Merge pull request Automattic#14899 from Automattic/IslandRhythms/fix-comments
standardize comment placement in lib/error
2 parents 75e1dd8 + 42ffada commit 0b81c6e

16 files changed

+129
-100
lines changed

lib/error/browserMissingSchema.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
const MongooseError = require('./mongooseError');
88

9+
/**
10+
* MissingSchema Error constructor.
11+
*/
912

1013
class MissingSchemaError extends MongooseError {
11-
/**
12-
* MissingSchema Error constructor.
13-
*/
14+
1415
constructor() {
1516
super('Schema hasn\'t been registered for document.\n'
1617
+ 'Use mongoose.Document(name, schema)');

lib/error/divergentArray.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
const MongooseError = require('./mongooseError');
99

10+
/**
11+
* DivergentArrayError constructor.
12+
* @param {Array<String>} paths
13+
* @api private
14+
*/
15+
1016
class DivergentArrayError extends MongooseError {
11-
/**
12-
* DivergentArrayError constructor.
13-
* @param {Array<String>} paths
14-
* @api private
15-
*/
17+
1618
constructor(paths) {
1719
const msg = 'For your own good, using `document.save()` to update an array '
1820
+ 'which was selected using an $elemMatch projection OR '

lib/error/invalidSchemaOption.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
const MongooseError = require('./mongooseError');
99

10+
/**
11+
* InvalidSchemaOption Error constructor.
12+
* @param {String} name
13+
* @api private
14+
*/
15+
1016
class InvalidSchemaOptionError extends MongooseError {
11-
/**
12-
* InvalidSchemaOption Error constructor.
13-
* @param {String} name
14-
* @api private
15-
*/
17+
1618
constructor(name, option) {
1719
const msg = `Cannot create use schema for property "${name}" because the schema has the ${option} option enabled.`;
1820
super(msg);

lib/error/missingSchema.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
const MongooseError = require('./mongooseError');
99

10+
/**
11+
* MissingSchema Error constructor.
12+
* @param {String} name
13+
* @api private
14+
*/
15+
1016
class MissingSchemaError extends MongooseError {
11-
/**
12-
* MissingSchema Error constructor.
13-
* @param {String} name
14-
* @api private
15-
*/
17+
1618
constructor(name) {
1719
const msg = 'Schema hasn\'t been registered for model "' + name + '".\n'
1820
+ 'Use mongoose.model(name, schema)';

lib/error/notFound.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
const MongooseError = require('./mongooseError');
88
const util = require('util');
99

10+
/**
11+
* OverwriteModel Error constructor.
12+
* @api private
13+
*/
14+
1015
class DocumentNotFoundError extends MongooseError {
11-
/**
12-
* OverwriteModel Error constructor.
13-
* @api private
14-
*/
16+
1517
constructor(filter, model, numAffected, result) {
1618
let msg;
1719
const messages = MongooseError.messages;

lib/error/objectExpected.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
const MongooseError = require('./mongooseError');
88

9+
/**
10+
* Strict mode error constructor
11+
*
12+
* @param {string} type
13+
* @param {string} value
14+
* @api private
15+
*/
916

1017
class ObjectExpectedError extends MongooseError {
11-
/**
12-
* Strict mode error constructor
13-
*
14-
* @param {string} type
15-
* @param {string} value
16-
* @api private
17-
*/
18+
1819
constructor(path, val) {
1920
const typeDescription = Array.isArray(val) ? 'array' : 'primitive value';
2021
super('Tried to set nested object field `' + path +

lib/error/objectParameter.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66

77
const MongooseError = require('./mongooseError');
88

9+
/**
10+
* Constructor for errors that happen when a parameter that's expected to be
11+
* an object isn't an object
12+
*
13+
* @param {Any} value
14+
* @param {String} paramName
15+
* @param {String} fnName
16+
* @api private
17+
*/
18+
919
class ObjectParameterError extends MongooseError {
10-
/**
11-
* Constructor for errors that happen when a parameter that's expected to be
12-
* an object isn't an object
13-
*
14-
* @param {Any} value
15-
* @param {String} paramName
16-
* @param {String} fnName
17-
* @api private
18-
*/
20+
1921
constructor(value, paramName, fnName) {
2022
super('Parameter "' + paramName + '" to ' + fnName +
2123
'() must be an object, got "' + value.toString() + '" (type ' + typeof value + ')');

lib/error/overwriteModel.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
const MongooseError = require('./mongooseError');
99

10+
/**
11+
* OverwriteModel Error constructor.
12+
* @param {String} name
13+
* @api private
14+
*/
1015

1116
class OverwriteModelError extends MongooseError {
12-
/**
13-
* OverwriteModel Error constructor.
14-
* @param {String} name
15-
* @api private
16-
*/
17+
1718
constructor(name) {
1819
super('Cannot overwrite `' + name + '` model once compiled.');
1920
}

lib/error/parallelSave.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
const MongooseError = require('./mongooseError');
88

9+
10+
/**
11+
* ParallelSave Error constructor.
12+
*
13+
* @param {Document} doc
14+
* @api private
15+
*/
16+
917
class ParallelSaveError extends MongooseError {
10-
/**
11-
* ParallelSave Error constructor.
12-
*
13-
* @param {Document} doc
14-
* @api private
15-
*/
18+
1619
constructor(doc) {
1720
const msg = 'Can\'t save() the same doc multiple times in parallel. Document: ';
1821
super(msg + doc._doc._id);

lib/error/parallelValidate.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
const MongooseError = require('./mongooseError');
88

99

10+
/**
11+
* ParallelValidate Error constructor.
12+
*
13+
* @param {Document} doc
14+
* @api private
15+
*/
16+
1017
class ParallelValidateError extends MongooseError {
11-
/**
12-
* ParallelValidate Error constructor.
13-
*
14-
* @param {Document} doc
15-
* @api private
16-
*/
18+
1719
constructor(doc) {
1820
const msg = 'Can\'t validate() the same doc multiple times in parallel. Document: ';
1921
super(msg + doc._doc._id);

0 commit comments

Comments
 (0)