Improve availability error messages with date context

- Added date to slot overlap error message
- Added date to invalid time range error message
- Makes errors more actionable for users
This commit is contained in:
counterweight 2025-12-21 17:59:18 +01:00
parent 131477b7f3
commit 3369a71271
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -100,7 +100,7 @@ async def set_availability(
if sorted_slots[i].end_time > sorted_slots[i + 1].start_time:
raise HTTPException(
status_code=400,
detail=f"Time slots overlap: {sorted_slots[i].end_time} > {sorted_slots[i + 1].start_time}",
detail=f"Time slots overlap on {request.date}: slot ending at {sorted_slots[i].end_time} overlaps with slot starting at {sorted_slots[i + 1].start_time}. Please ensure all time slots are non-overlapping.",
)
# Validate each slot's end_time > start_time
@ -108,7 +108,7 @@ async def set_availability(
if slot.end_time <= slot.start_time:
raise HTTPException(
status_code=400,
detail=f"Slot end time must be after start time: {slot.start_time} - {slot.end_time}",
detail=f"Invalid time slot on {request.date}: end time {slot.end_time} must be after start time {slot.start_time}. Please correct the time range.",
)
# Delete existing availability for this date