Skip to content

Revise the typed throws design #10

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

Merged
merged 1 commit into from
Jun 16, 2025
Merged

Revise the typed throws design #10

merged 1 commit into from
Jun 16, 2025

Conversation

natecook1000
Copy link
Member

This changes the conventions for typed throws for the parser initializers that used the conditionally-defined ThrownParsingError type alias. Some of the parsers didn't actually need that alias, and instead could use a function-specific generic error.

For others parsers, the library now provides two overloads: one with ParsingError-typed errors and one with untyped errors, which is omitted in embedded contexts. Since it is more specific, the typed- error overload is chosen when a passed-in closure either does not throw or throws only ParsingErrors.

This also reworks the methods in "ParserSource.swift" with the only thing still really using ThrownParsingError being the ExpressibleByParsing protocol, since it is significantly more wide open than the lower-level parsers.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

This changes the conventions for typed throws for the parser
initializers that used the conditionally-defined `ThrownParsingError`
type alias. Some of the parsers didn't actually need that alias,
and instead could use a function-specific generic error.

For others parsers, the library now provides two overloads: one with
`ParsingError`-typed errors and one with untyped errors, which is
omitted in embedded contexts. Since it is more specific, the typed-
error overload is chosen when a passed-in closure either does not
throw or throws only `ParsingError`s.
@natecook1000 natecook1000 merged commit cba000e into main Jun 16, 2025
13 checks passed
@natecook1000 natecook1000 deleted the typed-throws-take-2 branch June 16, 2025 19:15
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.

1 participant