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

tour: handle error rather than print both #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crisman
Copy link
Contributor

@crisman crisman commented Mar 20, 2023

In "tour/methods/20" ("Exercise: Errors") just after the slide explaining "calling code should handle errors by testing whether the error equals nil" the example code in the errors exercise provides a main that calls functions expecting error values and does not check them. Checking error values is the expected go way of doing things and should be shown. In the successful case it is also odd to show the "nil" of no error when printing the correct answer (see golang/tour#273). Printing the likely undefined float64 root value when there is an error is also confusing.

Update "methods/exercise-errors.go" and matched solution to only print error on error and only root otherwise.

Fixes golang/tour#273
Fixes golang/tour#230

In "tour/methods/20" ("Exercise: Errors") just after the slide
explaining "calling code should handle errors by testing whether the
error equals nil" the example code in the errors exercise provides a
main that calls functions expecting error values and does not check
them. Checking error values is the expected go way of doing things and
should be shown. In the successful case it is also odd to show the "nil"
of no error when printing the correct answer (see golang/tour#273).
Printing the likely undefined float64 root value when there is an
error is also confusing.

Update "methods/exercise-errors.go" and matched solution to only print
error on error and only root otherwise.

Fixes golang/tour#273
Fixes golang/tour#230
@gopherbot
Copy link
Contributor

This PR (HEAD: 625960b) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/website/+/477615 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

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