try catch message

This commit is contained in:
CHIEFSOFT\ameye
2024-08-28 07:29:02 -04:00
parent bc1490d780
commit 57e0ec548b
+17 -9
View File
@@ -49,7 +49,7 @@ WRENCHJOB_EMAIL_PASS='may12002!'
const mailMessage = this.parseEmailFile('depend_job_added'); const mailMessage = this.parseEmailFile('depend_job_added');
const tempVal = this.getTemplateValues(mailMessage); const tempVal = this.getTemplateValues(mailMessage);
console.log("MATCHED VALUES =>", tempVal); console.log("MATCHED VALUES =>", tempVal);
const transporter = nodemailer.createTransport({ const transporter = nodemailer.createTransport({
service: "gmail", service: "gmail",
host: `${emailServer}`, host: `${emailServer}`,
@@ -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 [];
}
} }
}; };