Remove github.com/pkg/errors with appropriate replacements (#3172)

* errors.Wrap* removal

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* remove errors.Errorf

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Remove remaining calls

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Few more errors

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Fix golint errors

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

---------

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2025-02-20 08:58:37 +05:30
committed by GitHub
parent 2fd44174ce
commit caffed92f4
113 changed files with 585 additions and 588 deletions
+8 -8
View File
@@ -1,20 +1,20 @@
package error
import (
"fmt"
"net/http"
"testing"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
func TestIsNotFound(t *testing.T) {
errs := map[error]bool{
nil: false,
MakeError(ErrorNotFound, "someone not found"): true,
MakeError(ErrorTooManyRequests, "too many requests"): false,
errors.Wrap(MakeError(ErrorNotFound, "someone not found"), "other information"): true,
errors.Wrap(MakeError(ErrorTooManyRequests, "too many requests"), "other information"): false,
MakeError(ErrorNotFound, "someone not found"): true,
MakeError(ErrorTooManyRequests, "too many requests"): false,
fmt.Errorf("other information: %w", MakeError(ErrorNotFound, "someone not found")): true,
fmt.Errorf("other information: %w", MakeError(ErrorTooManyRequests, "too many requests")): false,
}
for err, want := range errs {
@@ -25,9 +25,9 @@ func TestIsNotFound(t *testing.T) {
func TestGetHTTPError(t *testing.T) {
errs := map[int]error{
http.StatusBadRequest: MakeError(ErrorInvalidArgument, ""),
http.StatusConflict: errors.Wrap(MakeError(ErrorNameExists, ""), ""),
http.StatusNotFound: errors.Wrap(MakeError(ErrorNotFound, ""), ""),
http.StatusTooManyRequests: errors.Wrap(MakeError(ErrorTooManyRequests, "too many requests"), "other information"),
http.StatusConflict: fmt.Errorf("%w", MakeError(ErrorNameExists, "")),
http.StatusNotFound: fmt.Errorf("%w", MakeError(ErrorNotFound, "")),
http.StatusTooManyRequests: fmt.Errorf("other information: %w", MakeError(ErrorTooManyRequests, "too many requests")),
}
for want, err := range errs {
code, _ := GetHTTPError(err)