Escaping silently back to repl

When using the toplevel (standard or utop), is there an exception that one can raise (or some other mechanism) that will exit evaluation and return to the repl without reporting an error?

The exception Toploop.PPerror would seem to do what I want but it’s not exported. And I’m not finding anything in Topeval.execute_phrase but perhaps I’m looking in the wrong place.

Also not clear how I would do it with a custom toplevel.

In particular, if I write:
# let x = compute_thing ();;
and compute_thing fails, I want to report the error myself and go back to the prompt.

You would need to write your own toplevel loop for that, I think.

Cheers,
Nicolas

1 Like