let warn msg = prerr_endline (sprintf "ocaml-http WARNING: %s" msg)
let error msg = prerr_endline (sprintf "ocaml-http ERROR: %s" msg)
+let finally at_end f arg =
+ let res =
+ try f arg
+ with exn -> at_end (); raise exn
+ in
+ at_end ();
+ res
+
val warn: string -> unit (** print a warning msg to stderr. Adds trailing \n *)
val error: string -> unit (** print an error msg to stderr. Adds trailing \n *)
+ (** @param finalizer finalization function (execution both in case of success
+ * and in case of raised exception
+ * @param f function to be invoked
+ * @param arg argument to be passed to function *)
+val finally: (unit -> unit) -> ('a -> 'b) -> 'a -> 'b
+