Tuesday, 3 December 2019

sequelize handling rejection in the create statement - catch not firing

The sequelize create statement has an error and I would like to handle that error. Since the create statement has the error I need to handle promise rejection. How do I do that in code? Tried to look at the sequelize documents but unable to work it out.

db.Employee.create(empData, {include:[{model: 
db.EmployeeDetails}]}).then(function(newEmployee){
    res.json(newEmployee);
}).catch(function(err){
  return next(err);
});

The error is on the create and so the webpage just gives an internal server error. I was under the impression that the catch was something that handled the promise rejection and failure. In this case, how can I handle the promise rejection in code. An example would be greatly appreciated.



from sequelize handling rejection in the create statement - catch not firing

No comments:

Post a Comment