I am trying to handle the error of mysql query for deleting.
`
When the error is occurring, instead of executing the response
function MySQL is throwing the error in the console and stopping the server.
`
This used to work before, but now it is not working now.
Is this because of any version of MySQL and nodejs??
.
I am using node js version: v10.6.0
.
MySQL connector version: ^2.16.0
.
.
I have created a relationship between two tables with restricting delete.
.
This is my code to delete an item from the table.
this.deletePurchaseBill = function (id) {
return new Promise(function (resolve, reject) {
var delete_purchase_bill_sql = `DELETE FROM purchase_entry_header WHERE id = '${id}'`;
conn.query(delete_purchase_bill_sql, function (err, result) {
console.log('error:' + err);
if (err) {
if (err.errno == 1451) {
resolve({
status: "error",
message: "This purchase can not be deleted",
debug: err,
});
} else {
resolve({
status: "error",
message: "Unexpected error occurred",
debug: err
});
}
} else {
resolve({
status: "success",
message: "Successfully Deleted"
});
}
});
});
};
.
Any help would be appriceated