try catch message
This commit is contained in:
+17
-9
@@ -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 [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user