Skip to content

Commit

Permalink
over error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
UTXOnly committed Mar 9, 2024
1 parent 2b62f21 commit 8cbbb30
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions docker_stuff/python_stuff/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,18 @@ async def handle_new_event(request: Request) -> JSONResponse:
return event_obj.evt_response(results_status="flase", http_status_code=200)

else:
await event_obj.add_event(conn, cur)
statsd.increment("nostr.event.added.count", tags=["func:new_event"])
try:
await event_obj.add_event(conn, cur)
statsd.increment("nostr.event.added.count", tags=["func:new_event"])
except psycopg.IntegrityError as e:
logger.debug(f"Entering integ loop")
conn.rollback()
logger.info(f"Event with ID {event_obj.event_id} already exists")
resp = event_obj.evt_response(
results_status="true", http_status_code=409, message="duplicate: already have this event"
)
logger.debug(f"resp integ error is {resp}")
return resp
return event_obj.evt_response(results_status="true", http_status_code=200)

except psycopg.IntegrityError as e:
Expand Down

0 comments on commit 8cbbb30

Please sign in to comment.