From c85a4f379652c8fb19031164b234c84f442db885 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 3 Apr 2019 06:59:05 +0200 Subject: [PATCH] Catch error from stripe call --- hosting/management/commands/fetch_stripe_bills.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hosting/management/commands/fetch_stripe_bills.py b/hosting/management/commands/fetch_stripe_bills.py index 89fffb27..7219341b 100644 --- a/hosting/management/commands/fetch_stripe_bills.py +++ b/hosting/management/commands/fetch_stripe_bills.py @@ -37,8 +37,11 @@ class Command(BaseCommand): user.stripecustomer.stripe_id, created=created_gt ) + if all_invoices_response['error'] is not None: + self.stdout.write(self.style.ERROR(all_invoices_response['error'])) + exit(1) all_invoices = all_invoices_response['response_object'] - self.stdout.write(self.style.SUCCESS("Obtained {} invoices".format(len(all_invoices)))) + self.stdout.write(self.style.SUCCESS("Obtained {} invoices".format(len(all_invoices) if all_invoices is not None else 0))) for invoice in all_invoices: MonthlyHostingBill.create( invoice, stripe_customer=user.stripecustomer