Created
January 14, 2022 01:34
-
-
Save emchristiansen/b5e1ad709c353a0253eca86182c89268 to your computer and use it in GitHub Desktop.
Unable to get stack traces when using Lwt.catch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let bar () : unit Lwt.t = | |
assert false ; | |
Lwt.return_unit | |
let foo () : unit Lwt.t = bar () | |
let run () : unit Lwt.t = foo () | |
let run_catch () : unit Lwt.t = | |
Lwt.catch run (fun exn -> | |
Format.printf | |
"@{<error>@{<title>Error@}@}@. @[<h 0>%a@]@." | |
Format.pp_print_text | |
(Printexc.to_string exn) ; | |
Lwt.return_unit) | |
let () = | |
print_endline "Start" ; | |
(* This version doesn't print a stack trace. *) | |
Lwt_main.run (run_catch ()) | |
(* This version does print a stack trace. *) | |
(* Lwt_main.run (run ()) *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment