diff --git a/backend/routes/booking.py b/backend/routes/booking.py index c4a7528..4ca135f 100644 --- a/backend/routes/booking.py +++ b/backend/routes/booking.py @@ -194,7 +194,7 @@ async def create_booking( if not matching_availability: raise HTTPException( status_code=400, - detail="Selected slot is not within available time ranges", + detail=f"Selected slot at {request.slot_start.strftime('%Y-%m-%d %H:%M')} UTC is not within any available time ranges for {slot_date}. Please select a different time slot.", ) # Create the appointment @@ -264,7 +264,10 @@ async def cancel_my_appointment( appointment = result.scalar_one_or_none() if not appointment: - raise HTTPException(status_code=404, detail="Appointment not found") + raise HTTPException( + status_code=404, + detail=f"Appointment with ID {appointment_id} not found. It may have been deleted or the ID is invalid.", + ) # Verify ownership if appointment.user_id != current_user.id: @@ -279,9 +282,10 @@ async def cancel_my_appointment( # Check if appointment is in the past if appointment.slot_start <= datetime.now(timezone.utc): + appointment_time = appointment.slot_start.strftime('%Y-%m-%d %H:%M') + " UTC" raise HTTPException( status_code=400, - detail="Cannot cancel a past appointment" + detail=f"Cannot cancel appointment scheduled for {appointment_time} as it is in the past or has already started." ) # Cancel the appointment @@ -356,7 +360,10 @@ async def admin_cancel_appointment( appointment = result.scalar_one_or_none() if not appointment: - raise HTTPException(status_code=404, detail="Appointment not found") + raise HTTPException( + status_code=404, + detail=f"Appointment with ID {appointment_id} not found. It may have been deleted or the ID is invalid.", + ) # Check if already cancelled if appointment.status != AppointmentStatus.BOOKED: @@ -367,9 +374,10 @@ async def admin_cancel_appointment( # Check if appointment is in the past if appointment.slot_start <= datetime.now(timezone.utc): + appointment_time = appointment.slot_start.strftime('%Y-%m-%d %H:%M') + " UTC" raise HTTPException( status_code=400, - detail="Cannot cancel a past appointment" + detail=f"Cannot cancel appointment scheduled for {appointment_time} as it is in the past or has already started." ) # Cancel the appointment