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

Requesting throwing alternative to body() #273

Open
bjo0 opened this issue Jul 8, 2024 · 5 comments
Open

Requesting throwing alternative to body() #273

bjo0 opened this issue Jul 8, 2024 · 5 comments

Comments

@bjo0
Copy link

bjo0 commented Jul 8, 2024

The signature for body() is:

func body() -> Element?

It would improve ergonomics if there was a version of this that threw, e.g.:

func body() throws -> Element

This would allow for better ergonomics at call sites that propagate errors, while not really diminishing the ergonomics for sites that want to deal in optionals, as try? is always available.

It wasn't immediately clear to me if try document.select("body") is an appropriate alternative for getting a throwing version of this.

@aehlke
Copy link
Collaborator

aehlke commented Aug 19, 2024

It sounds good but I wouldn't want to break the existing API to make this change alone and don't think it's worth adding a 2nd new function to opt into this new behavior

@bjo0
Copy link
Author

bjo0 commented Aug 20, 2024

By this you mean that you include adding a case to the error enum as a breaking change?

Maybe this can go on a wishlist for the next major semver, if ever one happens?

@aehlke
Copy link
Collaborator

aehlke commented Aug 20, 2024

I mean changing it to be throwing would require everyone to update their code

I think no one is managing a wish list, this is all volunteer effort

@bjo0
Copy link
Author

bjo0 commented Aug 20, 2024 via email

@aehlke
Copy link
Collaborator

aehlke commented Dec 11, 2024

Hey sorry for late reply - I'm not sure I understand the last comment right now but if you submit a PR that does something like adding a new route instead of changing existing code to throwing, that's great and yes I think I get you now, reuse across the 2 is great. Thanks...

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

No branches or pull requests

2 participants