Skip to content

Commit

Permalink
capturing errors in sentry after handling them
Browse files Browse the repository at this point in the history
  • Loading branch information
derekeder committed Mar 15, 2024
1 parent a7b0452 commit 40e2d7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion chicago/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.utils.feedgenerator import Rss201rev2Feed
from django.urls import reverse, reverse_lazy
from django.conf import settings
from sentry_sdk import capture_exception

from .models import ChicagoPerson, Bill, Organization, Event
from .utils import to_datetime
Expand Down Expand Up @@ -76,7 +77,8 @@ def item_link(self, bill):
def item_pubdate(self, bill):
try:
return to_datetime(bill.last_action_date)
except AttributeError:
except AttributeError as e:
capture_exception(e)
return None

def description(self, obj):
Expand Down
7 changes: 6 additions & 1 deletion chicago/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from django.views.generic import TemplateView, DetailView, ListView
from haystack.generic_views import FacetedSearchView
from haystack.forms import FacetedSearchForm
from sentry_sdk import capture_exception

from opencivicdata.core.models import Membership
from opencivicdata.legislative.models import (
BillSponsorship,
Expand Down Expand Up @@ -614,11 +616,14 @@ def get_context_data(self, **kwargs):
event_orgs = event.participants.filter(entity_type="organization")
context["event_orgs"] = event_orgs
for event_org in event_orgs:
if event_org.organization:
try:
org_members = event_org.organization.memberships.filter(
start_date__lte=event.start_time, end_date__gte=event.start_time
).select_related("person__councilmatic_person")
expected_attendees.update([m.person for m in org_members])
except AttributeError as e:
# found an event without an organization
capture_exception(e)

attendees = set()
for event_person in event.attendance:
Expand Down

0 comments on commit 40e2d7e

Please sign in to comment.