Review and sanitize the pretty-printing of errors
CDuce's internal code base relies heavily on exceptions for error messages. Due to the various places error can occur, exceptions are not always correctly handled when they should. Some examples :
- Lexing/Parsing errors (static)
- Typing errors (static)
- Compilation errors (static but should be an internal failure, since compilation is not supposed to fail)
- CDuce exceptions (exceptions raised by CDuce code on purpose, dynamic)
- OCaml exceptions (exceptions raised by OCaml code on purpose, dynamic, e.g. if a user calls
OCaml.Stdlib.List.hd []
) - Runtime exceptions (some corner features of CDuce require dynamic checks, such that pattern-matching against a primitive or polymorphic function)
And there are also warnings. And internal exceptions used for control flow that should never be used. The use of all these exceptions should be surveyed, sanitized and documented. Most exceptions are caught in lang/lib/cduce_driver in a way that is not completely satisfactory (and maybe some are not).
This might require cleaning up the handling of locations first which is its own can of worm (lang/parser/cduce_loc.ml). In particular, it is still polluted by remnants of the HTML output (CDuce could be run as a CGI script for the online toplevel, which has been replaced by the JavaScript back-end that do not require a server-side component).
Once the surveying is done, a more robust error/warning infrastructure can be put in place.