mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
better error handling in email (#6599)
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
7120bb2558
commit
9f277f67b5
@ -330,7 +330,7 @@ module.exports = ({ env }) => ({
|
||||
This plugin will allow configurations for each active environment.
|
||||
|
||||
```bash
|
||||
npm install strapi-provider-upload-aws-s3@beta
|
||||
npm install strapi-provider-upload-aws-s3
|
||||
```
|
||||
|
||||
#### 4. Push your local changes to your project's GitHub repository.
|
||||
|
||||
@ -35,7 +35,7 @@ To install a new provider run:
|
||||
::: tab yarn
|
||||
|
||||
```
|
||||
yarn add strapi-provider-email-sendgrid@beta --save
|
||||
yarn add strapi-provider-email-sendgrid --save
|
||||
```
|
||||
|
||||
:::
|
||||
@ -43,7 +43,7 @@ yarn add strapi-provider-email-sendgrid@beta --save
|
||||
::: tab npm
|
||||
|
||||
```
|
||||
npm install strapi-provider-email-sendgrid@beta --save
|
||||
npm install strapi-provider-email-sendgrid --save
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
@ -8,7 +8,15 @@
|
||||
module.exports = {
|
||||
send: async ctx => {
|
||||
let options = ctx.request.body;
|
||||
await strapi.plugins.email.services.email.send(options);
|
||||
try {
|
||||
await strapi.plugins.email.services.email.send(options);
|
||||
} catch (e) {
|
||||
if (e.statusCode === 400) {
|
||||
return ctx.badRequest(e.message);
|
||||
} else {
|
||||
throw new Error(`Couldn't send email: ${e.message}.`);
|
||||
}
|
||||
}
|
||||
|
||||
// Send 200 `ok`
|
||||
ctx.send({});
|
||||
|
||||
@ -26,7 +26,7 @@ module.exports = {
|
||||
|
||||
client.sendEmail(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ module.exports = {
|
||||
|
||||
mailgun.messages().send(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ module.exports = {
|
||||
|
||||
sendgrid.send(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ module.exports = {
|
||||
|
||||
sendmail(removeUndefined(msg), err => {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user