diff --git a/controllers/v2/unavailability/api.py b/controllers/v2/unavailability/api.py index ef01ed6b..093186f7 100644 --- a/controllers/v2/unavailability/api.py +++ b/controllers/v2/unavailability/api.py @@ -7,6 +7,7 @@ from controllers.v2.v2_blueprint import v2_api import logging from exception import EventNotFoundError, InvalidArgumentError + edit_parser = reqparse.RequestParser() edit_parser.add_argument("title", type=str) edit_parser.add_argument("start", type=inputs.datetime_from_iso8601) @@ -42,16 +43,18 @@ def put(self, user_id, event_id): @requires_auth @is_user_or_has_role(None, UserType.ROOT_ADMIN) def delete(self, user_id, event_id): + # logging is used for easier debugging try: success = self.event_repository.remove_event(user_id, event_id) if success: - # If the event is successfully removed, return HTTP 200 OK. + logging.info(f"Soft deleted unavailability event {event_id} for user {user_id}.") return {"message": "Unavailability event removed successfully."}, 200 else: - # If the event does not exist or could not be removed, return HTTP 404 Not Found. - return {"message": "Unavailability event not found."}, 404 + logging.warning( + f"Attempted to remove non-existing or already removed event {event_id} for user {user_id}.") + return {"message": "Unavailability event not found or already removed."}, 404 except Exception as e: - # HTTP 500 Internal Server Error + logging.error(f"Error during deletion of event {event_id} for user {user_id}: {str(e)}") return {"message": "Internal server error", "error": str(e)}, 500