Answer the question
In order to leave comments, you need to log in
How to handle errors in mongoose?
How to handle errors such as writing a new document whose field should be unique but repeated?
At the moment, it brings down the whole process (
I know that you can rewrite the texts of errors in your own way, like
// customize within each schema or globally like so
var mongoose = require('mongoose');
mongoose.Error.messages.String.enum = "Your custom message for {PATH}.";
mongoose.connection.on('error',function(err){
log.error('Could not connect to mongo server!');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question