Skip to content

Commit

Permalink
Use reraise instead of fail in more places in ppx
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael-proust committed Feb 7, 2024
1 parent 9f22077 commit 7113b11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ppx/ppx_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
Expand Down Expand Up @@ -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 })

Expand Down
4 changes: 2 additions & 2 deletions src/ppx/ppx_lwt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7113b11

Please sign in to comment.