-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved error reporting api (WIP) #2190
Conversation
The proposal looks good to me. I think the Sexp.t to Dyn.t change should be done in a separate PR however. |
Seems reasonable |
I'm happy to start learning how to use So the change seems good to me! |
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This PR has been split in various PRs that have all been merged. The underlying implementation of a few modules could still be improved, but at least the way to report errors in now completely formalised. |
The current error reporting API is a bit complex, we have too many functions to report user errors and many error messages are not cut properly and contains very long lines.
This PR proposes a new simpler API that makes it easier to construct well formatted error messages.
All error reporting functions are replaced by only two:
User_error.raise
andCode_error.raise
. At this point, this PR only partially updatesStdune
and a couple of call sites in src. I'd like to get some feedback on the new API before refactoring the whole code base.user errors
User errors are errors that users need to fix themselves in order to make progress. Since these errors are read by users, they should be simple to understand for people who are not familiar with the dune codebase.
This functions takes an optional location as well a list of paragraphs. Each paragraph starts on a new line and the first one is prefixed by
Error:
.One noticeable point is the use of
Pp.t
ratherFormat
format strings. I personally find it difficult to produce well formatted error messages using theFormat
or evenFmt
API. In practice, greppingtest/blackbox-tests/test-cases
reveals that many error messages contain lines that are longer than 80 characters even thoughFormat
uses a margin of 80 characters by default, so I'm guessing that this is a general problem.On the other hand, the
Pp
API makes it easier to construct arbitrarily complex messages programmatically that are well formatted.The
Style.t
type indicate the that parts of the message might be styled with styles such asError
,Details
, ...code errors
Code errors are errors that are due to programming errors and should be reported upstream. Since they are aimed at Dune developers, these don't need to be human readable and can leak internal details of the Dune codebase, such as the representation of internal data structures.
The API is the same as before, except that we now use
Dyn.t
rather thanSexp.t
.