(style lwt ppx dep) Use try%lwt over Lwt.catch

This commit is contained in:
Elliott Cable 2023-06-13 22:50:52 +00:00
parent de0d5ea197
commit 3e46458499
5 changed files with 15 additions and 14 deletions

View file

@ -1,4 +1,3 @@
open Lwt.Syntax
module Atomic = Opentelemetry_atomic.Atomic
let[@inline] ( let@ ) f x = f x

View file

@ -2,5 +2,6 @@
(name opentelemetry_client_cohttp_lwt)
(public_name opentelemetry-client-cohttp-lwt)
(synopsis "Opentelemetry collector using cohttp+lwt+unix")
(preprocess (pps lwt_ppx))
(libraries opentelemetry lwt cohttp-lwt cohttp-lwt-unix pbrt mtime
mtime.clock.os))

View file

@ -105,11 +105,11 @@ end = struct
let body = Cohttp_lwt.Body.of_string bod in
let* r =
Lwt.catch
(fun () ->
let+ r = Httpc.post ~headers ~body uri in
Ok r)
(fun e -> Lwt.return @@ Error e)
try%lwt
let+ r = Httpc.post ~headers ~body uri in
Ok r
with e ->
Lwt.return @@ Error e
in
match r with
| Error e ->

View file

@ -2,4 +2,6 @@
(name opentelemetry_lwt)
(public_name opentelemetry-lwt)
(synopsis "Lwt frontend for opentelemetry")
(preprocess
(pps lwt_ppx))
(libraries lwt opentelemetry))

View file

@ -47,14 +47,13 @@ module Trace = struct
in
emit ?service_name [ span ]
in
Lwt.catch
(fun () ->
let* x = f scope in
let () = finally (Ok ()) in
Lwt.return x)
(fun e ->
let () = finally (Error (Printexc.to_string e)) in
Lwt.fail e)
try%lwt
let* x = f scope in
let () = finally (Ok ()) in
Lwt.return x
with e ->
let () = finally (Error (Printexc.to_string e)) in
Lwt.fail e
end
module Metrics = struct