This repository was archived by the owner on Oct 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Embed errors in the AST instead of raising #65
Copy link
Copy link
Open
Description
Currently, when ppx_mysql encounters an error, it uses the raise_errorf function to raise a located error.
The exception is caught by ppxlib, which in this case:
- Catch the error,
- stops the rewriting process
- add the error (as a
[%%%ocaml.error ...]extension node) to the last valid ast - Use the resulting AST
The interruption of the rewriting is quite bad for the user experience! The implication for the users are:
- Since
ppx_mysqlruns at the "context-free" phase, the "last valid AST" is before the context-free phase. So, no other derivers/extenders get run, which generates a lot of noise in the errors (such as "uninterpreted extensions" or "unbound identifiers") - Only one (meaningful) error from your PPX is reported at a time.
Example
For instance:
let invalid1 = [%mysql invalid ""]
let invalid2 = [%mysql invalid ""]
let valid = [%mysql select_one ""]would report several errors:
I don't understand query action 'invalid'forinvalid1(the right error)- 'Uninterpreted extension 'mysql'
forinvalid1,invalid2andvalid`.
The right error for invalid2 is not shown, and the "uninterpreted extension" errors add a lot of noise!
You can find more information about error reporting in PPXs in this section of the ppxlib manual.
❓ Would you be willing to accept contributions to this issue? I'm considering assigning its resolution as part of an outreachy internship: see more information here.
Metadata
Metadata
Assignees
Labels
No labels