Skip to content
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

handle name attribute in errors correctly #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EmileTrotignon
Copy link
Contributor

I added better error messages previously, but they ignored the [@name "..."] attribute. Its now correctly taken into account.

I added a test case in errors.t :

  Fatal error: exception Ppx_deriving_json_runtime.Of_json_error(Json_error {|expected ["A"] or ["Foo"] or ["B", _] or ["C", _, _] or ["D", { _ }] or ["different_name"] but got ["B", 123, "booh"]|})

Before this patch this would have been :

  Fatal error: exception Ppx_deriving_json_runtime.Of_json_error(Json_error {|expected ["A"] or ["Foo"] or ["B", _] or ["C", _, _] or ["D", { _ }] or ["Different_name"] but got ["B", 123, "booh"]|})

Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a small nit, otherwise looks good.

Don't forget to snapshot the tests.

Comment on lines 527 to +531
let name = c.pcd_name in
let name =
Option.value ~default:name
(vcs_attr_json_name (Vcs_ctx_variant c))
in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let name = c.pcd_name in
let name =
Option.value ~default:name
(vcs_attr_json_name (Vcs_ctx_variant c))
in
let name =
let name = c.pcd_name in
Option.value ~default:name
(vcs_attr_json_name (Vcs_ctx_variant c))
in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants