Skip to content

Commit d460fbc

Browse files
committed
add try/catch blocks for sending mail
1 parent 0c384d4 commit d460fbc

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

server/utils/mail.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ class Mail {
1919
}
2020

2121
async sendMail(mailOptions) {
22-
const response = await this.client.sendMail(mailOptions);
23-
return response;
22+
try {
23+
const response = await this.client.sendMail(mailOptions);
24+
return response;
25+
} catch (error) {
26+
console.error('Failed to send email: ', error);
27+
throw new Error('Email failed to send.');
28+
}
2429
}
2530

2631
async send(data) {
@@ -31,8 +36,13 @@ class Mail {
3136
html: data.html
3237
};
3338

34-
const response = await this.sendMail(mailOptions);
35-
return response;
39+
try {
40+
const response = await this.sendMail(mailOptions);
41+
return response;
42+
} catch (error) {
43+
console.error('Error in prepping email.', error);
44+
throw new Error('Error in prepping email.');
45+
}
3646
}
3747
}
3848

0 commit comments

Comments
 (0)