Open
Milestone
started on Feb 9, 2024
Refactor of Exceptions
Milestone ID: 17
@kn Issues:
- Unhandled exceptions are not shown to the user as the corresponding tag of the constructor of
error_t
is replaced by_
. There is a failing test that shows this. - Add new exceptions to the remaining
failwith
s in the code. - Do a similar refactor for warnings.
- The exception
Typer_Error
is used many times in theTyper
module with different big error messages. A good idea might be to break it into smaller exceptions. - The same thing at a smaller degree for
Patterns_Error
in the modulePatterns
. - Change long name of tags in
error_t
to an argument for the constructor with the corresponding variant. (e.g.Typer_Error of string
becomesError of string * mod
, where mod has all possible modules). - The
Generic
exception defined inCduce_loc
is defined twice: once inCduce_loc
and replicated inCduce_error
. This is obviously bad, but we can't remove the one inCduce_loc
since it is raised inside this module. The other places where it is raised I substituted by the version inCduce_error
. Maybe there is a better way to do it. - Print the backtrace for unhandled exceptions.
- Maybe add more "bad" tests. Even though there are many kinds of exceptions in the code, I only saw a few of them being raised in the tests.
- Replace the exceptions defined in
Types
(Sequence_Error
,Ns_Uri_Not_unique
andNs_Label_Not_unique
) by a value ofresult
type parametrized by the corresponding payload of the exception, so we can handle them inlang/
without creating a dependency cicle.