Skip to content

Commit

Permalink
added error handling for duplicate index 85,86 to throw warn not error
Browse files Browse the repository at this point in the history
  • Loading branch information
Juyoun Kim committed Nov 7, 2023
1 parent 98e693d commit a30d737
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,21 @@ module.exports = function (sails) {
options
);
} catch (err) {
sails.log.error(
"Mongoat: Error creating index for model",
modelName
);
sails.log.error(fields);
sails.log.error(err);
if (err.code === 85 || err.code === 86) {
sails.log.warn(
"Mongoat: Error creating index for model",
modelName
);
sails.log.warn(fields);
sails.log.warn(err);
} else {
sails.log.error(
"Mongoat: Error creating index for model",
modelName
);
sails.log.error(fields);
sails.log.error(err);
}
}
if (_.isFunction(next)) {
next(err);
Expand Down

0 comments on commit a30d737

Please sign in to comment.