try catch message

This commit is contained in:
CHIEFSOFT\ameye
2024-08-28 07:29:02 -04:00
parent bc1490d780
commit 57e0ec548b
+16 -8
View File
@@ -108,14 +108,22 @@ WRENCHJOB_EMAIL_PASS='may12002!'
if(!sentence){ if(!sentence){
return 'no sentence given' // RETURNS NOT FOUND IF NO SENSENCE WAS GIVEN return 'no sentence given' // RETURNS NOT FOUND IF NO SENSENCE WAS GIVEN
} }
const regexToTest = /\{\{(.*?)\}\}/g; // EXPRESSION TO MATCH IN THE GIVEN SENTENCE
const regexForBrackets = /[\{{ |\}}]/g; // EXPRESSION TO ELIMINATE CURLY BRACKETS try {
const matches = sentence.match(regexToTest) // ARRAY OF MATCHED VALUES const regexToTest = /\{\{(.*?)\}\}/g; // EXPRESSION TO MATCH IN THE GIVEN SENTENCE
if(matches && matches.length > 0){ const regexForBrackets = /[\{{ |\}}]/g; // EXPRESSION TO ELIMINATE CURLY BRACKETS
const returnedValues = matches.map(item => item.replace(regexForBrackets,'')) //STRIP OUT CURLY BRACKETS const matches = sentence.match(regexToTest) // ARRAY OF MATCHED VALUES
return returnedValues if(matches && matches.length > 0){
} const returnedValues = matches.map(item => item.replace(regexForBrackets,'')) //STRIP OUT CURLY BRACKETS
return []; return returnedValues
}
return [];
} catch (error) {
console.error(error);
return [];
}
} }
}; };