diff --git a/lib/oca_lib.ml b/lib/oca_lib.ml index 0e73265..b709fe1 100644 --- a/lib/oca_lib.ml +++ b/lib/oca_lib.ml @@ -29,7 +29,7 @@ let get_files dirname = aux (file :: files) end begin function | End_of_file -> Lwt.return files - | exn -> Lwt.fail exn + | exn -> raise exn end in aux [] >>= fun files -> @@ -66,12 +66,12 @@ let pread ?cwd ?exit1 ~timeout cmd f = | _, _ -> let cmd = String.concat " " cmd in prerr_endline ("Command '"^cmd^"' failed (exit status: "^string_of_int n^"."); - Lwt.fail (Failure "process failure") + failwith "process failure" end | Unix.WSIGNALED n | Unix.WSTOPPED n -> let cmd = String.concat " " cmd in prerr_endline ("Command '"^cmd^"' killed by a signal (n°"^string_of_int n^")"); - Lwt.fail (Failure "process failure") + failwith "process failure" end let read_unordered_lines c = @@ -118,7 +118,7 @@ let mkdir_p dir = Lwt_unix.mkdir (Fpath.to_string dir) 0o750 end begin function | Unix.Unix_error (Unix.EEXIST, _, _) -> Lwt.return_unit - | e -> Lwt.fail e + | e -> raise e end [@ocaml.warning "-fragile-match"] >>= fun () -> aux dir xs in @@ -144,7 +144,7 @@ let rec rm_rf dirname = in Lwt.catch rm_files begin function | End_of_file -> Lwt.return_unit - | e -> Lwt.fail e + | e -> raise e end end begin fun () -> Lwt_unix.closedir dir >>= fun () -> diff --git a/server/backend/admin.ml b/server/backend/admin.ml index f96b288..80c594c 100644 --- a/server/backend/admin.ml +++ b/server/backend/admin.ml @@ -70,7 +70,7 @@ let admin_action ~on_finished ~conf ~run_trigger workdir body = | ["set-processes"; i] -> let i = int_of_string i in if i < 0 then - Lwt.fail_with "Cannot set the number of processes to a negative value." + failwith "Cannot set the number of processes to a negative value." else Server_configfile.set_processes conf i >|= fun () -> (fun () -> Lwt.return_none) @@ -112,7 +112,7 @@ let admin_action ~on_finished ~conf ~run_trigger workdir body = | ["log"] -> get_log workdir | _ -> - Lwt.fail_with "Action unrecognized." + failwith "Action unrecognized." end >>= fun resp -> let stream = Lwt_stream.from resp in Cohttp_lwt_unix.Server.respond ~status:`OK ~body:(`Stream stream) () @@ -143,7 +143,7 @@ let callback ~on_finished ~conf ~run_trigger workdir _conn _req body = | Some (pversion, body) when String.equal Oca_lib.protocol_version pversion -> begin match String.Split.left ~by:"\n" body with | Some (_, "") -> - Lwt.fail_with "Empty message" + failwith "Empty message" | Some (user, body) -> get_user_key workdir user >>= fun key -> let body = decrypt key body in @@ -151,12 +151,12 @@ let callback ~on_finished ~conf ~run_trigger workdir _conn _req body = | Some (user', body) when String.equal user user' -> admin_action ~on_finished ~conf ~run_trigger workdir body | Some _ -> - Lwt.fail_with "Identity couldn't be ensured" + failwith "Identity couldn't be ensured" | None -> - Lwt.fail_with "Identity check required" + failwith "Identity check required" end | None -> - Lwt.fail_with "Cannot find username" + failwith "Cannot find username" end | Some (pversion, _) -> Cohttp_lwt_unix.Server.respond_string @@ -166,4 +166,4 @@ let callback ~on_finished ~conf ~run_trigger workdir _conn _req body = Please upgrade your client.") () | None -> - Lwt.fail_with "Cannot parse request" + failwith "Cannot parse request" diff --git a/server/backend/check.ml b/server/backend/check.ml index b42cb91..ec3200e 100644 --- a/server/backend/check.ml +++ b/server/backend/check.ml @@ -109,7 +109,7 @@ let ocluster_build_str ~debug ~cap ~conf ~base_obuilder ~stderr ~default c = Lwt.return r | (Error (), _) -> match default with - | None -> Lwt.fail_with ("Failure in ocluster: "^c) (* TODO: Replace this with "send message to debug slack webhook" *) + | None -> failwith ("Failure in ocluster: "^c) (* TODO: Replace this with "send message to debug slack webhook" *) | Some v -> Lwt.return v let failure_kind logfile = @@ -410,7 +410,7 @@ let get_cap ~stderr ~cap_file = Lwt.return sr | Error _ -> Lwt_io.write_line stderr "cap file couldn't be loaded" >>= fun () -> - Lwt.fail_with "cap file not found" + failwith "cap file not found" let run_locked = ref false diff --git a/server/lib/cache.ml b/server/lib/cache.ml index add6dab..06ce730 100644 --- a/server/lib/cache.ml +++ b/server/lib/cache.ml @@ -195,7 +195,7 @@ let get_html ~conf self query logdir = let get_latest_logdir self = self.logdirs >>= function - | [] -> Lwt.fail Not_found + | [] -> raise Not_found | logdir::_ -> Lwt.return logdir let get_html ~conf self query logdir = diff --git a/server/lib/server.ml b/server/lib/server.ml index de1e59b..21b7cc8 100644 --- a/server/lib/server.ml +++ b/server/lib/server.ml @@ -122,7 +122,7 @@ module Make (Backend : Backend_intf.S) = struct (* TODO: Try to understand why it wouldn't do anything before when this was ~on_exn *) Lwt.catch (fun () -> callback ~conf backend conn req body) - (fun e -> if debug then prerr_endline (Printexc.get_backtrace () ^ Printexc.to_string e); Lwt.fail e) + (fun e -> if debug then prerr_endline (Printexc.get_backtrace () ^ Printexc.to_string e); raise e) let tcp_server port callback = Cohttp_lwt_unix.Server.create