diff --git a/sefaria/helper/crm/salesforce.py b/sefaria/helper/crm/salesforce.py index a2dbddd4b0..8f040993f3 100644 --- a/sefaria/helper/crm/salesforce.py +++ b/sefaria/helper/crm/salesforce.py @@ -168,5 +168,5 @@ def get_available_lists(self) -> list[str]: response = self.get(endpoint + "?q=SELECT+Subscriptions__c+FROM+AC_to_SF_List_Mapping__mdt") records = response.json()["records"] return [record["Subscriptions__c"] for record in records] - except (requests.RequestException, KeyError, json.JSONDecodeError): + except (requests.RequestException, KeyError, json.JSONDecodeError, AttributeError): raise SalesforceNewsletterListRetrievalError("Unable to retrieve newsletter mailing lists from Salesforce CRM") diff --git a/sefaria/views.py b/sefaria/views.py index 56a571620b..bc446589b1 100644 --- a/sefaria/views.py +++ b/sefaria/views.py @@ -222,7 +222,7 @@ def get_available_newsletter_mailing_lists(request): try: return jsonResponse({"newsletter_mailing_lists": CrmMediator().get_available_lists()}) except SalesforceNewsletterListRetrievalError as e: - return jsonResponse({"error": e.message}, status=502) + return jsonResponse({"error": str(e)}, status=502) except: return jsonResponse({"error": "Unknown error occurred"}, status=500)