Skip to content
Snippets Groups Projects
Commit 6538023d authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Make sure that errors are displayed as string in logger in order to avoid more error

parent 45ebb742
Branches
Tags
1 merge request!4Version 1.2.2
Pipeline #2444 passed
{
"name": "service-email",
"version": "1.2.1",
"version": "1.2.2",
"description": "description",
"author": "",
"license": "MIT",
......
......@@ -106,14 +106,14 @@ export class EmailService {
const transporter = Nodemailer.createTransport(this.config.smtpConfig);
await transporter.verify().catch((error) => {
this.logger.error('SMTP connection failed.', error, `${EmailService.name} - ${this.send.name}`);
this.logger.error('SMTP connection failed.', `${error}`, `${EmailService.name} - ${this.send.name}`);
throw new InternalServerErrorException({ error, message: 'SMTP connection failed.' });
});
this.logger.log('SMTP Server is ready to receive messages', `${EmailService.name} - ${this.send.name}`);
await transporter.sendMail(email).catch((error) => {
this.logger.error('Couldn\'t send email.', error, `${EmailService.name} - ${this.send.name}`);
this.logger.error('Couldn\'t send email.', `${error}`, `${EmailService.name} - ${this.send.name}`);
transporter.close();
throw new InternalServerErrorException({ error, message: 'Couldn\'t send email.' });
});
......
......@@ -22,7 +22,7 @@ export class SmtpHealthIndicator extends HealthIndicator {
const transporter = Nodemailer.createTransport(this.configService.config.smtpConfig);
await transporter.verify().catch((error) => {
this.logger.error('SMTP connection failed.', error, `${SmtpHealthIndicator.name} - ${this.checkSMTPConnection.name}`);
this.logger.error('SMTP connection failed.', `${error}`, `${SmtpHealthIndicator.name} - ${this.checkSMTPConnection.name}`);
transporter.close();
throw new HealthCheckError('SMTP connection failed', error);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment