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

About error propagation on Must chained function implementations #677

Closed
state303 opened this issue Aug 9, 2022 · 5 comments
Closed

About error propagation on Must chained function implementations #677

state303 opened this issue Aug 9, 2022 · 5 comments
Labels
duplicate This issue or pull request already exists question Questions related to rod

Comments

@state303
Copy link

state303 commented Aug 9, 2022

Rod Version: v0.108.2

A Question...

Consider one might utilize a Must func chaining...

...
url := "somewhere"

// if using Must chaining...
text := p.MustNavigate(url).MustElement("ul > li").MustText()

// otherwise one might do...
if err := p.Navigate(url); err == nil {
  handleErr(err)
  return
}
elem, err := p.Element("ul > li")
if err != nil {
  handleErr(err)
  return
}
... // on and on... or...

// what if...
text, err := p.MustNavigate(url).MustElement("ul > li").MustText().Do() // Do() will terminate the function call
...

I believe that usage of Must chaining already implies that the developer giving up the conciseness on error handling, in exchange of readability.

I looked into some PRs (more specifically for #428 AND #433); panics can only be handled via panic handler from browser end.

By the nature of the current Must chaining implementation, I imagine a bit of tweaks could keep us away from panic handling, by propagating the initial error. But, again, i assume there has been countless discussions upon this issue.

So... I would like to know whether there is any ongoing discussion behind this issue, or even this being an issue any longer.

Eagerly waiting for response 👍

@state303 state303 added the question Questions related to rod label Aug 9, 2022
@rod-robot
Copy link

Please fix the format of your markdown:

3:14 MD026/no-trailing-punctuation Trailing punctuation in heading [Punctuation: '...']
40:32 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]

Please fix the golang code in your markdown:

@@ golang markdown block 1 @@
3:1: expected statement, found '...'
19:1: expected statement, found '...'
24:2: expected ';', found 'EOF'
24:2: expected '}', found 'EOF'

generated by check-issue

@ysmood
Copy link
Member

ysmood commented Aug 9, 2022

Check this one: #166

@ysmood ysmood added the duplicate This issue or pull request already exists label Aug 9, 2022
@state303
Copy link
Author

state303 commented Aug 9, 2022

@ysmood Thank you! I will look into it 👍

@state303
Copy link
Author

state303 commented Aug 9, 2022

I do agree on the part where it is more error prone. But still I do believe there could...(?) be a better way.
I will close this issue for now. Hopefully I could bring some useful PR about it.

Thank you!

@state303 state303 closed this as completed Aug 9, 2022
@ysmood
Copy link
Member

ysmood commented Aug 9, 2022

Sure, I'd really like a better design. I'm looking forward to your ideas 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Questions related to rod
Projects
None yet
Development

No branches or pull requests

3 participants