Skip to content

Glossary: Go Beyond the Basics

wrapping errors (%w)

Also written: %w, fmt.Errorf, wrap

`fmt.Errorf("...: %w", err)` makes a new error that adds context but keeps the original inside, so `errors.Is` and `errors.As` can still find it.

Where the book teaches it

Related terms

errors.Iserrors.As