add Server.run_exn

This commit is contained in:
Simon Cruanes 2023-07-11 10:01:33 -04:00
parent ecc9f07748
commit ec2f2f6f2e
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 16 additions and 13 deletions

View file

@ -1085,15 +1085,14 @@ let is_ipv6 (self : t) =
let (module B) = self.backend in
is_ipv6_str (B.init_addr ())
(* TODO: init TCP server *)
let run ?(after_init = ignore) (self : t) : (unit, _) result =
try
let run_exn ?(after_init = ignore) (self : t) : unit =
let (module B) = self.backend in
let server = B.tcp_server () in
server.serve
~after_init:(fun tcp_server ->
self.tcp_server <- Some tcp_server;
after_init ())
~handle:(client_handler self) ();
Ok ()
with e -> Error e
~handle:(client_handler self) ()
let run ?after_init self : _ result =
try Ok (run_exn ?after_init self) with e -> Error e

View file

@ -606,9 +606,13 @@ val run : ?after_init:(unit -> unit) -> t -> (unit, exn) result
it exits with an error.
@param after_init is called after the server starts listening. since 0.13 .
*)
val run_exn : ?after_init:(unit -> unit) -> t -> unit
(** [run_exn s] is like [run s] but re-raises an exception if the server exits
with an error.
@since NEXT_RELEASE *)
(**/**)
val _debug :