improvement: better error handling

This commit is contained in:
canove
2020-09-04 17:09:39 -03:00
parent 3cb3fc1a20
commit f7fe3286b8
23 changed files with 166 additions and 532 deletions

View File

@@ -6,7 +6,16 @@ exports.store = async (req, res, next) => {
const io = getIO();
const wbot = getWbot();
const phoneContacts = await wbot.getContacts();
let phoneContacts;
try {
phoneContacts = await wbot.getContacts();
} catch (err) {
console.log(err);
return res.status(500).json({
error: "Could not check whatsapp contact. Check connection page.",
});
}
await Promise.all(
phoneContacts.map(async ({ number, name }) => {