How can you not pause the application when errors occur (in the mongoose nodejs express)?

54
November 24, 2020, at 8:00 PM

I use it mongoose nodejs express. When a validation error or mongoose error arc occurs, the application stops. How can you not pause the application when errors occur? Here are the sections of interest:

      try {
              await user.save( err => { if (err) {
              console.log("Ошибка записи mongoose: '/dayscreate/createday  err:'", err );
              req.flash('dayscreateErrMessage', "Error saved mongoose: '/dayscreate/createday'");
              return res.status(422).redirect('/dayscreate')
              }
              });
            return res.redirect('/incoming');
            
          } catch (e) {
            console.log('e=', e);
          }

In addition, there is middleware after:

module.exports = function(req, res, next) {
    res.status(404).render("404", {
        title: "Page not found"
    })
}```
After a program crash, forwarding to the page:
'/ incoming', accordingly an error connecting to the server
READ ALSO
Node.js fast-csv synchronously read file and return array

Node.js fast-csv synchronously read file and return array

I am trying to read acsv file and to assign it to an array with this code:

34
I want to upload a file to file.cm from telegram

I want to upload a file to file.cm from telegram

I want to upload a file to filecm from telegram, but I could not find any case studies on this topic

36
how do i solve this mistake i'm going crazy

how do i solve this mistake i'm going crazy

enter image description here

46
Inserting HTML snippet into an HTML file using node.js

Inserting HTML snippet into an HTML file using node.js

I'm doing some webscraping using puppeteer and want to store the HTML snippets I scrape inside an existing file

46