From 4d98a0a934c677833d68fc00a61f1cfd7320fa12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 7 Feb 2024 11:24:17 +0100 Subject: [PATCH] Use reraise instead of fail in more places in ppx --- src/ppx/ppx_lwt.ml | 6 +++--- src/ppx/ppx_lwt.mli | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ppx/ppx_lwt.ml b/src/ppx/ppx_lwt.ml index c2030be23..e77486c1a 100644 --- a/src/ppx/ppx_lwt.ml +++ b/src/ppx/ppx_lwt.ml @@ -23,7 +23,7 @@ let add_wildcard_case cases = if not has_wildcard then cases @ (let loc = Location.none in - [case ~lhs:[%pat? exn] ~guard:None ~rhs:[%expr Lwt.fail exn]]) + [case ~lhs:[%pat? exn] ~guard:None ~rhs:[%expr Lwt.reraise exn]]) else cases (** {3 Internal names} *) @@ -154,11 +154,11 @@ let lwt_expression mapper exp attributes ext_loc = Some (mapper#expression { new_exp with pexp_attributes }) (* [assert%lwt $e$] ≡ - [try Lwt.return (assert $e$) with exn -> Lwt.fail exn] *) + [try Lwt.return (assert $e$) with exn -> Lwt.reraise exn] *) | Pexp_assert e -> let new_exp = let loc = !default_loc in - [%expr try Lwt.return (assert [%e e]) with exn -> Lwt.fail exn] + [%expr try Lwt.return (assert [%e e]) with exn -> Lwt.reraise exn] in Some (mapper#expression { new_exp with pexp_attributes }) diff --git a/src/ppx/ppx_lwt.mli b/src/ppx/ppx_lwt.mli index 1d3a541e6..0912c07e0 100644 --- a/src/ppx/ppx_lwt.mli +++ b/src/ppx/ppx_lwt.mli @@ -80,10 +80,10 @@ catch (fun () -> f x) prerr_endline msg; return () | exn -> - Lwt.fail exn) + Lwt.reraise exn) ]} - Note that the [exn -> Lwt.fail exn] branch is automatically added + Note that the [exn -> Lwt.reraise exn] branch is automatically added when needed. - finalizer: