2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Updated error code for incorrect recipients in GhostMailer

no issue

- By default, GhostMailer throws EmailError with statusCode as `500` for any failure in sending mail
- In case of failure due to `RecipientError`, status code as now correctly sent as `400` as its a bad request and not an error we can't handle.
This commit is contained in:
Rish 2020-07-21 01:05:06 +05:30
parent 6232981be7
commit e8511d0568

View file

@ -48,9 +48,11 @@ function createMessage(message) {
function createMailError({message, err, ignoreDefaultMessage} = {message: ''}) {
const fullErrorMessage = defaultErrorMessage + message;
let statusCode = err.name === 'RecipientError' ? 400 : 500;
return new errors.EmailError({
message: ignoreDefaultMessage ? message : fullErrorMessage,
err: err,
statusCode,
help: helpMessage
});
}