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 tempVal = this.getTemplateValues(mailMessage);
|
||||
console.log("MATCHED VALUES =>", tempVal);
|
||||
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: "gmail",
|
||||
host: `${emailServer}`,
|
||||
@@ -108,14 +108,22 @@ WRENCHJOB_EMAIL_PASS='may12002!'
|
||||
if(!sentence){
|
||||
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
|
||||
const matches = sentence.match(regexToTest) // ARRAY OF MATCHED VALUES
|
||||
if(matches && matches.length > 0){
|
||||
const returnedValues = matches.map(item => item.replace(regexForBrackets,'')) //STRIP OUT CURLY BRACKETS
|
||||
return returnedValues
|
||||
}
|
||||
return [];
|
||||
|
||||
try {
|
||||
const regexToTest = /\{\{(.*?)\}\}/g; // EXPRESSION TO MATCH IN THE GIVEN SENTENCE
|
||||
const regexForBrackets = /[\{{ |\}}]/g; // EXPRESSION TO ELIMINATE CURLY BRACKETS
|
||||
const matches = sentence.match(regexToTest) // ARRAY OF MATCHED VALUES
|
||||
if(matches && matches.length > 0){
|
||||
const returnedValues = matches.map(item => item.replace(regexForBrackets,'')) //STRIP OUT CURLY BRACKETS
|
||||
return returnedValues
|
||||
}
|
||||
return [];
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user