Use errors.As instead of type-casting, errors.Is for comparison and
use of %w for error formatting in fmt.Errorf. The changes do not fully
fix all of errorlint. I don't feel comfortable touching files under v1-3
as this may break compatibility with api users.
Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>