diff --git a/backend/src/libs/wbot.ts b/backend/src/libs/wbot.ts index 49c0224..cf6626b 100644 --- a/backend/src/libs/wbot.ts +++ b/backend/src/libs/wbot.ts @@ -92,7 +92,9 @@ export const getWbot = (whatsappId: number): Session => { const sessionIndex = sessions.findIndex(s => s.id === whatsappId); if (sessionIndex === -1) { - throw new AppError("This WhatsApp session is not initialized."); + throw new AppError( + "This WhatsApp session is not initialized. Check connections page." + ); } return sessions[sessionIndex]; }; diff --git a/backend/src/services/ContactServices/CreateContactService.ts b/backend/src/services/ContactServices/CreateContactService.ts index e1d258d..66fbfc1 100644 --- a/backend/src/services/ContactServices/CreateContactService.ts +++ b/backend/src/services/ContactServices/CreateContactService.ts @@ -28,8 +28,6 @@ const CreateContactService = async ({ throw new AppError("A contact with this number already exists."); } - console.log("extra", extraInfo); - const contact = await Contact.create( { name, diff --git a/backend/src/services/WbotServices/CheckIsValidContact.ts b/backend/src/services/WbotServices/CheckIsValidContact.ts index dc9edd6..9ec0c27 100644 --- a/backend/src/services/WbotServices/CheckIsValidContact.ts +++ b/backend/src/services/WbotServices/CheckIsValidContact.ts @@ -10,10 +10,13 @@ const CheckIsValidContact = async (number: string): Promise => { try { const isValidNumber = await wbot.isRegisteredUser(`${number}@c.us`); if (!isValidNumber) { - throw new AppError("The suplied number is not a valid Whatsapp number"); + throw new AppError("invalidNumber"); } } catch (err) { console.log(err); + if (err.message === "invalidNumber") { + throw new AppError("This is not a valid whatsapp number."); + } throw new AppError( "Could not valid WhatsApp contact. Check connections page" );