Skip to content

Commit

Permalink
fix(email subscriptions): Fix referring to nonexistent field on excep…
Browse files Browse the repository at this point in the history
…tion object and catching another type of exception during error
  • Loading branch information
relyks committed Dec 23, 2024
1 parent 879d892 commit a676872
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sefaria/helper/crm/salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion sefaria/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a676872

Please sign in to comment.