Remove redundant try/catch block
This commit is contained in:
1 parent
17ed90f76b
commit
b69d495206
1 file changed
+6
-17
@@ -44,7 +44,7 @@ class EmailService {
|
|||||||
const templateContent = this.fs.readFileSync(templatePath, "utf8");
|
const templateContent = this.fs.readFileSync(templatePath, "utf8");
|
||||||
return this.compile(templateContent);
|
return this.compile(templateContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Error loading Email templates", {
|
this.logger.error("Error loading Email templates", {
|
||||||
error,
|
error,
|
||||||
service: this.SERVICE_NAME,
|
service: this.SERVICE_NAME,
|
||||||
});
|
});
|
||||||
@@ -102,7 +102,7 @@ class EmailService {
|
|||||||
const html = await this.mjml2html(mjml);
|
const html = await this.mjml2html(mjml);
|
||||||
return html.html;
|
return html.html;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Error building Email HTML", {
|
this.logger.error("Error building Email HTML", {
|
||||||
error,
|
error,
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
});
|
});
|
||||||
@@ -118,26 +118,15 @@ class EmailService {
|
|||||||
});
|
});
|
||||||
return info;
|
return info;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Error sending Email", {
|
this.logger.error("Error sending Email", {
|
||||||
error,
|
error,
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const html = await buildHtml(template, context);
|
||||||
try {
|
const info = await sendEmail(to, subject, html);
|
||||||
const info = await sendEmail(to, subject, await buildHtml(template, context));
|
return info?.messageId;
|
||||||
return info.messageId;
|
|
||||||
} catch (error) {
|
|
||||||
error.service = SERVICE_NAME;
|
|
||||||
if (error.method === undefined) {
|
|
||||||
error.method = "buildAndSendEmail";
|
|
||||||
}
|
|
||||||
logger.error("Error building and sending Email", {
|
|
||||||
error,
|
|
||||||
service: SERVICE_NAME,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export default EmailService;
|
export default EmailService;
|
||||||
Reference in new issue
Block a user