Go course

ErrorsQuiz: Errors

Go

Display

Theme

Errors · Quiz

Quiz: Errors

Test your understanding of error handling in Go: errors.New, fmt.Errorf, wrapping with %w, errors.Is, errors.As, and when to use panic.

  1. Question 1 of 5What is the definition of Go's built-in error interface?
  2. Question 2 of 5What does the following code print?
    var ErrPenuh = errors.New("kelas penuh")
    
    err := fmt.Errorf("daftar kelas yoga: %w", ErrPenuh)
    fmt.Println(err == ErrPenuh, errors.Is(err, ErrPenuh))
  3. Question 3 of 5What's the difference between %v and %w in fmt.Errorf?
  4. Question 4 of 5You have a custom error type ErrHTTP with a Kode field. The error may already have been wrapped several times. The right way to read Kode is...
  5. Question 5 of 5A function reads a config file, and the file isn't found. What should the function do?