Skip to content
Snippets Groups Projects
Commit 576d67af authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

refactor(newsletter): add error detail

parent 481d2181
No related branches found
No related tags found
1 merge request!375V3.0.0
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment