While using the nested `callbacks` or `promises` or `async/await` where one set of tasks gets executed first which are in `await` condition and then only it proceeds further on **success**; I would like to know then what to do if an **error** occured in between to any **middle task**?

Since after that none tasks will be executed as the operations will come to **halt** now.
But due to this when this end point is called the whole process becomes incomplete since some initial tasks gets executed and comes to halt in between and remaining tasks also get paused/stopped.

So this whole situation becomes incomplete and shabby.

How to deal with this?

Below is the example of code I am dealing with multiple routes in my project where I am using the nested callbacks. And when one tasks gets error the below whole process gets stopped since error has been occured.

```
  router.route('/addTasks-approve').get(function(req, res) {

                      User.updateMany({'Addtasks.commonID':req.query.id},
                         {$set: {"Addtasks.$.width" :'250px',
                          "Addtasks.$.height" :'32px',
                          "Addtasks.$.background" :'linear-gradient(45deg, #0f3443, #34e89e)',
                          "Addtasks.$.border_radius" :'10px / 5px',
                         "Addtasks.$.status" :req.query.text}},
                        function (error, success) {
                              if (!error) {
                                console.log("Approved color set!");
                                User.findOne({tag:'Admin','Addtasks.commonID':req.query.id},function (error, dataAdmin) {
                                      if (error) {
                                          console.log("error = "+ error);
                                          res.end('{"msg" : "Some error occurred", "status" : 700}');
                                      }
                                      else {
                                        dataAdmin.Addtasks.forEach(element => {
                                          if(element.commonID == req.query.id)
                                          {
                                     User.findOneAndUpdate({tag:'Client','Addtasks.commonID':req.query.id},
                                     {$push: {'Addtasks.$.Bigpaths4Clients':{$each : element.Bigpaths4Clients}},
                                      $set: {"Addtasks.$.background" :'linear-gradient(45deg, #1E6305, #BDFF00)',
                                             "Addtasks.$.status" :'Done'}},
                                        function (error, data) {
                                              if (error) {
                                                console.log("error = "+ error);
                                                res.end('{"msg" : "Unable to add the Task", "status" : 700}');
                                              }
                                              else {
                                                console.log("Addtasks added to Client's dashboard succesfully");
                                                sendMails2Client(data.email, element.topic, 'In Progress', 'Done');
                                                sendMails2User(dataAdmin.email, element.topic, 'Done', 'Approved');
                                                User.findOne({tag:'Admin','Addtasks.commonID':req.query.id},function (error, dataWriter) {
                                                      if (error) {
                                                          console.log("error = "+ error);
                                                          res.end('{"msg" : "Some error occurred", "status" : 700}');
                                                      }
                                                      else {
                                                        sendMails2User(dataWriter.email, element.topic, 'Done', 'Approved');
                                                        res.end('{"success" : "success", "status" : 200}');
                                                      }
                                                    })
                                              }
                                      })
                                    }
                                  });
                                }
                              });
                              }
                              else {
                                res.end('{"msg" : "Unable to set the status and color for Approved", "status" : 700}');
                              }
                            });
                                                  });

```