From 6538023dcae3ffd6e0e88fe2a65d609ad5638d59 Mon Sep 17 00:00:00 2001 From: FORESTIER Fabien <fabien.forestier@soprasteria.com> Date: Mon, 24 Jun 2019 16:36:54 +0200 Subject: [PATCH] Make sure that errors are displayed as string in logger in order to avoid more error --- package.json | 2 +- src/email/email.service.ts | 4 ++-- src/health/smtp.healthIndicator.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7bbeb3d..1bab6bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-email", - "version": "1.2.1", + "version": "1.2.2", "description": "description", "author": "", "license": "MIT", diff --git a/src/email/email.service.ts b/src/email/email.service.ts index d4dfa83..a703ec2 100644 --- a/src/email/email.service.ts +++ b/src/email/email.service.ts @@ -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.' }); }); diff --git a/src/health/smtp.healthIndicator.ts b/src/health/smtp.healthIndicator.ts index d7f7199..109cb44 100644 --- a/src/health/smtp.healthIndicator.ts +++ b/src/health/smtp.healthIndicator.ts @@ -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); }); -- GitLab