Skip to content

Commit 5996922

Browse files
committed
Add specific 404 error handling to get_liturgy_of_the_day
- Add 404 status code check in HTTPStatusError exception handler - Provide user-friendly error message for calendar not found - Log calendar details (type, id, year) when 404 occurs - Matches error handling pattern used in other calendar functions Addresses Copilot feedback on line R351
1 parent 9c7cc3b commit 5996922

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

litcal_server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ async def get_liturgy_of_the_day(
349349
logger.exception("Error")
350350
return f"❌ Error: {str(e)}"
351351
except httpx.HTTPStatusError as e:
352+
if e.response.status_code == 404:
353+
logger.error(
354+
"Calendar not found for type %s, id %s, year %s",
355+
calendar_type_case.value,
356+
calendar_id,
357+
target_date.year,
358+
)
359+
return f"❌ Calendar not found for {calendar_type_case.value} calendar"
352360
logger.exception("HTTP error fetching liturgy")
353361
return f"❌ HTTP error: {e.response.status_code} - {e.response.text}"
354362
except httpx.RequestError as e:

0 commit comments

Comments
 (0)