toplevel uncaught exception handling #13037
Unanswered
AlexisHamon
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I don't understand the toplevel behavior about uncaught exceptions.
Because runtime exceptions to the interpreted code are caught by the toplevel code with standard output:
But they should remain uncaught exceptions from the interpreted code view, so maybe they should be treated as errors with output on
stderr
instead ofstdout
(There exists a mitigation using
Printexc.print
in each toplevel command)In fact, if I swap the default uncaught exception handler with
Printexc.set_uncaught_exception_handler
which should affect our code when there is uncaught exception in our interpreted code, it does not because exceptions are caught by the toplevel.This comportment appears very obvious on web toplevels because lex/par errors/warn appears in red/yellow while runtime errors are treated just as standard output because it is quite the case in the toplevel code.
ocaml/toplevel/byte/topeval.ml
Lines 180 to 183 in e72d835
My proposition is that we may want to create another
execute_phrase_verbose
function for people to access toOphr_eval
Ophr_signature
Ophr_exception
. In that case, we would be able to raise an exception or change the behavior if we wanted to. In addition, we can useexecute_phrase_verbose
inexecute_phrase
to avoid code duplication.That we maybe implies adding
Ophr_directive
to the type for the other part of thematch
witch is returning a boolean fromocaml/toplevel/topcommon.ml
Line 344 in e72d835
Beta Was this translation helpful? Give feedback.
All reactions