DaggieBlanqx / whatsappcloudapi_wrapper

An easy way to build Whatsapp Chatbots on top of the new Whatsapp Cloud API
129 stars 66 forks source link

Break down conditional checks for error message specificity. #1

Closed kbuika closed 2 years ago

kbuika commented 2 years ago

@DaggieBlanqx this is just a minor enhancement that ensures error messages are very specific.

Instead of having compound conditional checks like

if (!button.title || button.title.length > 20) {
    throw new Error(
         '"title" is required in making a request. The button title must be between 1 and 20 characters long.'
     );
}

Separating the conditions makes the error message much more specific

So the conditions will now become

 if (!button.title) {
     throw new Error(
         '"title" is required in making a request.'
     );
}
if (button.title.length > 20) {
    throw new Error(
       'The button title must be between 1 and 20 characters long.'
     );
}

Also, I have noticed there is still some work required for better error handling, I am happy to help with this or anything else that is a priority for the project :)

DaggieBlanqx commented 2 years ago

Thank you for pointing that out. I am happy to have you on board.