- if List.for_all tutors#exists tutor_ids then begin
- clients#subscribe client_id tutor_ids;
- return_hbugs_msg (Subscribed (my_own_id, tutor_ids)) outchan
- end else (* required subscription to an unexistent tutor *)
- let tutor_id =
- List.find (fun id -> not (tutors#exists id)) tutor_ids
- in
- return_hbugs_exc "tutor_not_found" tutor_id outchan
+ if List.length tutor_ids <> 0 then begin (* at least one tutor id *)
+ if List.for_all tutors#exists tutor_ids then begin
+ clients#subscribe client_id tutor_ids;
+ Hbugs_messages.respond_msg
+ (Subscribed (my_own_id, tutor_ids)) outchan
+ end else (* required subscription to at least one unexistent tutor *)
+ let missing_tutors =
+ List.filter (fun id -> not (tutors#exists id)) tutor_ids
+ in
+ Hbugs_messages.respond_exc
+ "tutor_not_found" (String.concat " " missing_tutors) outchan
+ end else (* no tutor id specified *)
+ Hbugs_messages.respond_exc "no_tutor_specified" "" outchan