go-dojo
learn go · earn mastery
phase 0 · 0.4-errors-as-values

Errors as values, not exceptions

prereqs 0.3-types-zero-values
review intervals 3d 7d 21d 60d drills err-idiom

The lesson for this task hasn't been written yet. The mastery criteria below is the shortest description of what you'll own when this task is green.

Mastery criteria

- Write a function that returns (T, error); handle every call with if err != nil
- Use fmt.Errorf with %w to wrap an underlying error
- Use errors.Is / errors.As to match a sentinel error in a test
- Articulate why there's no try/catch in Go and what changes about how you think about failure

Verify

Run from your go-dojo repo root:

go-dojo verify 0.4-errors-as-values

This runs the task's go test suite in exercises/phase-0/0.4-errors-as-values/, commits the attempt to .go-dojo/attempts/, and updates your mastery.