Below you will see a very simple code implementation of a wrapped error message. Use the errors.Unwrap function to print the original error message.
Errors
Unwrapping errors
Report a typo
Write a program in Go
package main
import (
"errors"
"fmt"
)
func main() {
err := errors.New("error: am I the original error?")
err = fmt.Errorf("error: no! I'm the original error! %w", err)
// call the errors.Unwrap function here and pass err as the argument
unwrappedErr := ?
// print the unwrapped error here
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.