error wrapping with %w and errors.Is not matching
I wrap a sentinel error with fmt.Errorf("fetch user: %w", ErrNotFound) but errors.Is(err, ErrNotFound) returns false. Go 1.22. I'm confused because I thought %w preserved the chain. What would break the chain? I feel like I'm missing something basic about how the wrap chain is built, since %w works fine elsewhere in the same repo and this is the only place it fails. I've traced every layer I can think of and keep coming back to the middleware.
4 replies