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

Export error constructors #5067

Closed
wants to merge 3 commits into from

Conversation

9999years
Copy link
Contributor

@9999years 9999years commented Aug 3, 2023

Fix for #5065. This exports the following Error constructors to improve diagnostic generation for TypedValueParser implementors:

  • Error::empty_value
  • Error::invalid_value
  • Error::value_validation

Additionally, this exports Error::set_source to provide a mechanism for custom error messages while still taking advantage of the context formatting.

Future work

Perhaps we should consider making public Error::invalid_subcommand, though I have no use for it at the moment.

@9999years 9999years force-pushed the export-error-constructors branch 2 times, most recently from 572157b to b6e6518 Compare August 3, 2023 23:40
This exports the following `Error` constructors to improve diagnostic
generation for `TypedValueParser` implementors:

- `Error::empty_value`
- `Error::invalid_value`
- `Error::value_validation`
This enables downstream consumers to set custom error messages and take
advantage of the `context` mechanism for annotating errors with the
provided arguments and values.

Fixes clap-rs#5065
@epage
Copy link
Member

epage commented Aug 4, 2023

More investigation is needed before we can consider making these APIs public as they increase our compatibility burden

@epage epage closed this Aug 4, 2023
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