'MERN app handling with MongoServerError and send as response

I have a node application using mongo db and Im trying to send back the MongoServerError if there is an error but i only can console.log it like i did in wsService.js here are my code: app.js

const errors = require('./helpers/errorHandler');
const users = require('./controllers/wsController')
app.use(errors.errorHandler)
app.use('/ws', ws)

wsModel.js:

const mongoose = require("mongoose");
const { Schema } = mongoose;

const wsSchema= new Schema({
    wsKey1: {
        type: String,
        required: true,
        unique: true,
    },
    wsKey2: {
        type: String,
        required: true,
    }
});


const WS =  mongoose.model("ws", wsSchema);

module.exports = WS;

wsService.js:

const WS = require('../models/wsModel')
const createNewInstance= async (object)=>{
    console.log(object)
    var newInstance = new WS(object)
    newInstance.save( (err, session)=> {
        if (err) console.log(err);
        console.log(session.wsKey1+ " saved to Open Sessions collection.");
        return session
      });
    return {
        "session":newInstance
        
    } 
   
}
module.exports = {
createNewInstance,
};

and my controller.js:

router.post('/createNewInstance', (req, res, next)=>{
    wsService.createNewInstance(req.body).then(
        (session) =>res.send(session)
    ).catch(
        err => next(err)
    )
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source