Conversation
Add Primitives.cleanup which allows handlers for unexpected exceptions to cleanup and reraise the exception with its backtrace.
Allow the runtime to display details of any uncaught exception (with backtraces, if enabled). Unix.handle_unix_error is still used to convert errors from system calls to a less unmeaningful form.
gasche
left a comment
There was a problem hiding this comment.
This looks generally good (and correctness-preserving) so here is a preliminary seal of approval.
I have two remarks:
-
I think the cleanup would be nicer with
cleanup : exn -> (unit -> 'a) -> 'athan your style of ofcleanup : exn -> ('a -> 'b) -> 'a -> 'b. Your callsites are less pleasant to read (even in the cases where they are more concise), and the type is more complex than it needs to be. -
I wonder why you haven't used the new and shiny
Fun.protectfunction. It would be a slightly more invasive patch (you have to factor out the commonalities in the success and failure path), but it would result in nicer code.
I don't know how excited you are about working more on this PR; I think the slightly-nicer API is really easy to do (if you agree it's a good idea; otherwise it is just bothersome), but the second point is more work and it's fine to not do it.
|
I'd simply forgotten about |
The caller is now always responsible for calling stop_user_input, rather than only responsible for calling it on error.
|
How's that? There are remaining cases where It's now a bit more of a reviewing challenge than it was before! I think I have preserved the same logic - care needed to ensure |
|
I agree that the previous handler of user input state in I think that a better solution would be to move Unrelated note: many of the use of |
|
I reviewed the other commits: they are fine and correct, but I think it would be nicer to rebase before merging because there is some back-and-forth. We could have two code commits, one for the user-input business (the trickier to review) and one for the rest (local/simple changes). |
Currently Fun.protect and Misc.try_finally can be used in code that tries carefully to preserve the first-failure backtrace, but Misc.protect_refs cannot. This PR fixes the discrepancy. See ocaml#9057 for a use-case. (no change entry needed)
Currently Fun.protect and Misc.try_finally can be used in code that tries carefully to preserve the first-failure backtrace, but Misc.protect_refs cannot. This PR fixes the discrepancy. See ocaml#9057 for a use-case. (no change entry needed)
Currently Fun.protect and Misc.try_finally can be used in code that tries carefully to preserve the first-failure backtrace, but Misc.protect_refs cannot. This PR fixes the discrepancy. See ocaml#9057 for a use-case. See the GPR ( ocaml#9060 ) for an in-depth discussion of the potential performance impact of this change.
Currently Fun.protect and Misc.try_finally can be used in code that tries carefully to preserve the first-failure backtrace, but Misc.protect_refs cannot. This PR fixes the discrepancy. See ocaml#9057 for a use-case. See the GPR ( ocaml#9060 ) for an in-depth discussion of the potential performance impact of this change.
Currently Fun.protect and Misc.try_finally can be used in code that tries carefully to preserve the first-failure backtrace, but Misc.protect_refs cannot. This PR fixes the discrepancy. See ocaml#9057 for a use-case. See the GPR ( ocaml#9060 ) for an in-depth discussion of the potential performance impact of this change.
|
@dra27 do you want to clean up the history, or can we just squash everything? You'll have to resolve the conflict in any case. |
13fb0de to
9eeead7
Compare
The failure in #9043 consisted of a helpful
Uncaught exception: Not_found! This PR updates the debugger to usePrintexc.raise_with_backtracein its handlers and also removes the use of the deprecatedPrintexc.catchsurroundingmain.(not for 4.10)