]> matita.cs.unibo.it Git - helm.git/blobdiff - DEVEL/ocaml-http/http_misc.ml
added finally function
[helm.git] / DEVEL / ocaml-http / http_misc.ml
index abe6702c2a0aedb11541ffd09b672248a633083f..daa81f3b7085d342f94d53e7a45a63eabce224f0 100644 (file)
@@ -144,3 +144,11 @@ let list_assoc_all key pairs =
 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
+