diff --git a/src/newsletter/newsletter.service.ts b/src/newsletter/newsletter.service.ts index 1203e197e9e8a91aa777706f6afb5a47a9bad468..cc4b79941b419fcc4582e103a8de5a47e78826fa 100644 --- a/src/newsletter/newsletter.service.ts +++ b/src/newsletter/newsletter.service.ts @@ -87,9 +87,15 @@ export class NewsletterService { return newsletterSubscription; } catch (e) { - if (e.status === 400 && e.response?.text?.includes('fake')) { - this.logger.log(`newsletterSubscribe: Fake or invalid email: ${email}`); - throw new HttpException('Fake or invalid email', HttpStatus.I_AM_A_TEAPOT); + if (e.status === 400) { + if (e.response?.text?.includes('fake')) { + this.logger.log(`newsletterSubscribe: Fake or invalid email: ${email}`); + throw new HttpException('Fake or invalid email', HttpStatus.I_AM_A_TEAPOT); + } else { + // Example: email "has signed up to a lot of lists very recently; we're not allowing more signups for now" + this.logger.error(`newsletterSubscribe ${email}: ${JSON.stringify(e)}`); + throw new HttpException(JSON.parse(e.response?.text)?.detail, HttpStatus.BAD_REQUEST); + } } else { this.logger.error(`newsletterSubscribe ${email}: ${JSON.stringify(e)}`); throw new HttpException('Subscribe error', HttpStatus.INTERNAL_SERVER_ERROR);