Q:

How do i produce multer error message in my postman

Im trying to res.status.send a multer error message to postman when my file image exceeds 1MB.  But when i try to run my code it only gives me this entire chunk of error message.  I just want to get the error message itself(LIMIT_FILE_SIZE).Is there any way to achieve this? 
IMAGE HERE
My current app.js:
var multer = require('multer');
var storage = multer.diskStorage({
    destination: function(req, file, callback) {
        callback(null, './uploads');
    },
    filename: function(req, file, callback) {
        callback(null, path.basename(file.originalname));
    }
})
const upload = multer({
    dest: storage,
    storage: storage,
    limits: {
      fileSize: 1024 * 1024
    },
    fileFilter: function(req, file, callback, error) {
        var ext = path.extname(file.originalname);
        var error_msg = error instanceof multer. MulterError
        if(ext ! == '.jpg') {
             req.fileValidationError = "Not a jpg file!"; 
             return callback(null, false, req.fileValidationError);
        }
        if(error_msg) {
            return callback(null, false, new MulterError('LIMIT_FILE_SIZE'))
        }
        callback(null,true)
    }

  });
app.post("/upload",upload.single('name'),(req,res,next) => {
if(req.fileValidationError) {
        res.status(500).send({message:req.fileValidationError});
    }
    else {
        if(error.code === 'LIMIT_FILE_SIZE') {
            req.fileSizeError = "Image more than 1MB!" 
            res.status(500).send({message:req.fileSizeError});
        }
        else {
            console.log('File Received!'); 
            console.log(req.file);
            var sql = "INSERT INTO `file`(name,description,type,size) VALUES('" + req.file.filename + "', '" + (req.file.encoding + "_" + req.file.destination + "_" + req.file.path)+ "', '" + req.file.mimetype + "', '" + req.file.size + "')";
            db.query(sql, (error, results) => {
                console.log('Inserted Data!'); 
            });
        const message = "Successfully Uploaded!" 
        res.status(200).send({message:message, file_details:req.file})
        }
    }
    })

A:

Multer delegates the error to Express which is the standard way of throwing errors in express.  To catch a specific error, you can use the multer upload middleware inside the route callback.  This is the method as given by multer's documentation, also mentioned by @Mattia Rasulo
router.post('/image', function (req, res, next) {
  upload.single('image')(req, res, function (error) {
    if (req.fileValidationError) {
      res.status(500).send({ message: req.fileValidationError });
    }
    else {
      if (error) {
        res.status(500).send({ message: error.code === 'LIMIT_FILE_SIZE' ? " Image more than 1MB!" :  error.message });
      }
      else {
        console.log('File Received!'); 
        console.log(req.file);
        var sql = "INSERT INTO `file`(name,description,type,size) VALUES('" + req.file.filename + "', '" + (req.file.encoding + "_" + req.file.destination + "_" + req.file.path)+ "', '" + req.file.mimetype + "', '" + req.file.size + "')";
        db.query(sql, (error, results) => {
            console.log('Inserted Data!'); 
        });
        const message = "Successfully Uploaded!" 
        res.status(200).send({message:message, file_details:req.file})
      }
    }
  });
});

