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
No related branches found
No related tags found
1 merge request!4Version 1.2.2
Pipeline #2444 passed
{ {
"name": "service-email", "name": "service-email",
"version": "1.2.1", "version": "1.2.2",
"description": "description", "description": "description",
"author": "", "author": "",
"license": "MIT", "license": "MIT",
......
...@@ -106,14 +106,14 @@ export class EmailService { ...@@ -106,14 +106,14 @@ export class EmailService {
const transporter = Nodemailer.createTransport(this.config.smtpConfig); const transporter = Nodemailer.createTransport(this.config.smtpConfig);
await transporter.verify().catch((error) => { 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.' }); throw new InternalServerErrorException({ error, message: 'SMTP connection failed.' });
}); });
this.logger.log('SMTP Server is ready to receive messages', `${EmailService.name} - ${this.send.name}`); this.logger.log('SMTP Server is ready to receive messages', `${EmailService.name} - ${this.send.name}`);
await transporter.sendMail(email).catch((error) => { 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(); transporter.close();
throw new InternalServerErrorException({ error, message: 'Couldn\'t send email.' }); throw new InternalServerErrorException({ error, message: 'Couldn\'t send email.' });
}); });
......
...@@ -22,7 +22,7 @@ export class SmtpHealthIndicator extends HealthIndicator { ...@@ -22,7 +22,7 @@ export class SmtpHealthIndicator extends HealthIndicator {
const transporter = Nodemailer.createTransport(this.configService.config.smtpConfig); const transporter = Nodemailer.createTransport(this.configService.config.smtpConfig);
await transporter.verify().catch((error) => { 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(); transporter.close();
throw new HealthCheckError('SMTP connection failed', error); 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