Commit 8700f8d8 authored by Johannes Kanig's avatar Johannes Kanig

P909-002 improve behavior when int_of_string fails

add exception handler for int_of_string failure and raise the correct
exception here
parent a5d0aa0b
......@@ -178,20 +178,24 @@ type answer =
| Started of int
| Finished of final_answer
let read_answer s = match Strings.split ';' s with
| "F":: id :: exit_s :: time_s :: timeout_s :: ( (_ :: _) as rest) ->
(* same trick we use in other parsing code. The file name may contain
';'. Luckily, the file name comes last, so we still split on ';',
and put the pieces back together afterwards *)
Finished { id = int_of_string id;
out_file = Strings.join ";" rest;
time = float_of_string time_s;
exit_code = int_of_string exit_s;
timeout = (timeout_s = "1"); }
| "S" :: [id] ->
Started (int_of_string id)
| _ ->
raise (InvalidAnswer s)
let read_answer s =
try
match Strings.split ';' s with
| "F":: id :: exit_s :: time_s :: timeout_s :: ( (_ :: _) as rest) ->
(* same trick we use in other parsing code. The file name may contain
';'. Luckily, the file name comes last, so we still split on ';',
and put the pieces back together afterwards *)
Finished { id = int_of_string id;
out_file = Strings.join ";" rest;
time = float_of_string time_s;
exit_code = int_of_string exit_s;
timeout = (timeout_s = "1"); }
| "S" :: [id] ->
Started (int_of_string id)
| _ ->
raise (InvalidAnswer s)
with Failure "int_of_string" ->
raise (InvalidAnswer s)
let read_answers ~blocking =
List.map read_answer (List.filter (fun x -> x <> "") (read_lines blocking))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment