go
go copied to clipboard
Implement new Concept Exercise: Error Wrapping
Getting Started
If you have not yet contributed to concept exercises before, this task requires some upfront reading to acquire the necessary background knowledge.
Here you can read about what Concept Exercises are and how they are structured:
Also be aware of these general guidelines.
Goal
The goal here is to create a new concept exercise that teaches error wrapping. That includes writing a concept and creating a new exercise.
Concepts
The following concept needs to be created. You can use the introduction.md file of the concept also as introduction.md file of the exercise. No need to create different content at this point. Additionally, if you want to save some time it is ok to not have an extensive about.md at this point. It can also be mainly the instruction.md content, maybe with some additions you would like to make.
-
error-wrapping
Learning Objectives
In the concepts the student should learn about the following topics and then practice them in the concept exercise.
- understanding the error chain
- how/when to use
errors.Is
anderrors.As
- how to wrap an error
- the
Unwrap
method for custom errors
The about.md file could additionally mention ...
- how to get a stack strace
We could potentially add some other advanced error topics if there are ideas.
Out of Scope
- error basics (Concept errors for what was already covered)
Prerequisites
-
errors
-
interfaces
-
type-assertions
Other prerequisites should be added as needed to solve the specific exercise.
Story Idea
There is probably no exercise that can be ported directly because Go's error handling is so special but here are some error related exercises from other tracks. The story could maybe be re-used even if we need to change the actual tasks.
- JavaScript "Factory Sensors" Exercise
- C# "Calculator Conundrum" Exercise
- Elixir "Stack Underflow" Exercise
Resources
Here some links that might be helpful as a starting point and/or for the links section of the concept:
- https://go.dev/blog/go1.13-errors
- https://pkg.go.dev/errors
Implementation Notes
- The
error-wrapping
concept folder and config.json entry already exists. No need to create those. - For the exercise, there is already a folder
deep-thought
that should be used and a config.json entry as well. You can rename the exercise folder, the slug and the exercise name to whatever you like, just keep the uuid fixed. You can remove the current content of the "Deep Thought". There was an issue in the past that there were two exercises started that were supposed to teacherrors
. In the end, one was actually finished up ("The Farm"). If we re-use the uuid of "deep-thought" we don't have to deprecate the exercise and have the "dead" folder lying around. As mentioned before, everything besides the UUID can be safely changed. "Deep Thought" was never finished/live.
How to proceed
- First accept this issue by saying "I'd like to work on this" (no need to wait for a response, just go ahead).
- Use this issue to discuss any questions you have, what should be included in the content and what not and to collect more reference material.
- Create a PR and set "exercism/go" as reviewers. Additionally you can write in #maintaining-go on Slack that your PR is ready for review. Once you incorporated any critical feedback that the reviewer might give you and the PR is approved, it will be merged by a maintainer.
Two notes (per #2013)
- When this lesson is done, the original errors lesson should be edited to include a forward reference to this lesson for more details about errors.
- This lesson should include a note that
errors.Is
is recommended instead of==
unless there is a specific reason not to unwrap the error.
See #2013 for background discussion.
Putting this on hold because of https://github.com/exercism/go/issues/2492.