-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
The Farm: Improve introduction #2011
Comments
A quote from @andrerfcsantos on Slack regarding the topic of the open task here:
|
To be quite honest, I think this might be a problem with the errors introduction, that it does not support or show learners the "Handle specific errors, but return others" explicitly.
I Was most frustrated as I did not see language I recognised as saying "Hey, we want to handle this error, but early exit all others." It pointed out a problem with how I approach golang; which I'll try to work on. But it could catch up anyone who is not an experienced and deep; regular gopher. I'd in-fact read the exercise as "We will only expect this error". How to communicate this... (suggestion)
The only other way I can think of is a flow diagram that basically hands the answer to all learners. |
@Lewiscowles1986 You raise a good point there. However, I think what you are bringing up is unrelated to the open task in this issue. It would be great, if you could open a new issue instead and copy your comment in there. Then we can discuss a bit more in that new issue. |
This issue and #2080 lead me to the question whether it is such a good idea to have the unusual pattern of "continue working with the result even though there was an error" as part of the concept exercise. As this is very rare, it might not be a good fit for the concept exercise that first introduces the student to the errors concept. It might even set a bad example. @andrerfcsantos How do you feel about this? Do you think we should change the exercise? That might avoid some bending the introduction around it. |
@junedev I agree we should change the exercise to not use the normal result of the function even though there was a non-nil error. Not only is a bit unrealistic like you said, but it might also unnecessarily make the exercise more complex. I think the idea is to show how to check for specific errors, but that's probably best done in the Error Wrapping concept. |
So, While I think this should leave this exercise, I also think it could be a separate exercise to wrapping, which to my mind serves a different purpose and is not encapsulation. Encapsulating an error and providing domain-specific knowledge / behavior is it's own standalone take on errors to wrapping. It is not a general concept, that people have a nephew who can't be fixed / changed cheaper than code. This is almost directly the opposite thing to wrapping the error, where for some reason that error detail would leak out to the world. You are not embedding past errors when encapsulating; you are exchanging an error for either another error, or providing a behavior for an error, that does not return an error. The original github.com/pkg/errors basically attempts to implement manual stack unwrapping ALA exceptions by-proxy. Like an Exception, it captures a stack trace for all errors; and provides a |
I'm happy to help on this task |
@mantrobuslawal If you want to make some small change related to the original open issue at the top, feel free to go ahead and create a PR. However, I would advise against bigger rework as we are planning to structurally change this exercise in the future (move interfaces into its own exercise and instead teach errors and error wrapping in one exercise). |
Here the issue for the rework I mentioned above: #2492 |
Follow up from #2009
The tests for "The Farm" currently don't cover what should happen when a negative fodder amount and a non-scale error is returned. Go's general guideline is to not use the result if there was an error so passing on the error takes precedence over handling the negative amount.
Tasks
DevideFood
is 0 and the error that was returned from FodderAmount.The text was updated successfully, but these errors were encountered: