errors: Introduce internal package
Created by: efritz
This PR replaces all references of github.com/cockroachdb/errors
and github.com/hashicorp/go-multierror
with imports restricted to a new internal package lib/errors
. This consolidation helps us restrict and control the ways that we can create, consume, and compare errors, and will allows us to control library behavior clashes such as multierror swallowing error values more easily in the future.
The problem we're tackling: The clash that's happening that I specifically want to fix comes from a weird combination of wrapping and unwrapping errors in a way that drops the original error in a chain. What happens is we'll see errors like "transaction aborted due to previous error", but we'll never be able to see what the original error that caused the additional ones.
Here is an image from the original slack discussion where we tried to pin this down.
I've been bit in customer issues since then, so I'm going to solve this.
An open problem: We have several go.mod files. I'm unable to cleanly import lib/errors
from the non-root project, as we can't relatively import modules outside of the workspace (e.g., can't go ../lib
from ./dev/bkstats
). For now, I've added all of the files that import these new disallowed packages to the golangci-lint ignorelist.