

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: The Error Interface
incomplete
2: Formatting Strings Review
incomplete
3: The Error Interface
incomplete
4: Errors Quiz
incomplete
5: The Errors Package
incomplete
6: Panic
incomplete
7: User Input
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The Go standard library provides an "errors" package that makes it easy to deal with errors.
Read the godoc for the errors.New() function, but here's a simple example:
var err error = errors.New("something went wrong")
Textio's software architects may have overcomplicated the requirements from the last coding assignment... oops. All we needed was a new generic error message that returns the string no dividing by 0 when a user attempts to get us to perform the taboo.
Complete the divide function. Use the errors.New() function to return an error when y == 0 that reads "no dividing by 0".
Remember that it's conventional to return the "zero" values of all other return values when you return a non-nil error in Go.