Reputation: 59956
I can create child record but what if not exist parent? this throw error which not able to catch in query catch with mysql DB.
but not able to catch this exception Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED. here is my code
models.sequelize
.authenticate()
.then(function () {
console.log('Connection successful');
res.send("connected")
})
.catch(function(error) {
console.log("Error creating connection:", error);
res.send(error)
});
i am only able to catch here but then how to response to user in this section?
process.on("unhandledRejection", function(reason, promise) {
//only able to handle here but not able to send this error in reponse
});
Although I used express Error handler but it still crash the application
Upvotes: 0
Views: 982
Reputation: 3326
This is an open bug in sequelize
https://github.com/sequelize/sequelize/issues/1854
You can listen 'on' event on connection to handle error when connection is closed
https://github.com/sequelize/sequelize/pull/2557
Upvotes: 1