mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 12:19:16 +00:00
improvement: error handling on contact creation
This commit is contained in:
@@ -10,10 +10,13 @@ const CheckIsValidContact = async (number: string): Promise<void> => {
|
||||
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"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user