Skip to content

Commit

Permalink
Drop the usage of pkg/errors in error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Oct 8, 2020
1 parent 19fe91d commit 9fda18e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/netext/httpext/error_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ package httpext
import (
"crypto/tls"
"crypto/x509"
stderrors "errors"
"errors"
"fmt"
"net"
"net/url"
"os"
"runtime"
"syscall"

"github.com/pkg/errors"
"golang.org/x/net/http2"

"github.com/loadimpact/k6/lib/netext"
Expand Down Expand Up @@ -108,17 +107,15 @@ func http2ErrCodeOffset(code http2.ErrCode) errCode {

// errorCodeForError returns the errorCode and a specific error message for given error.
func errorCodeForError(err error) (errCode, string) {
causeErr := errors.Cause(err)

inner := stderrors.Unwrap(causeErr)
if inner != nil && inner != causeErr {
inner := errors.Unwrap(err)
if inner != nil && inner != err {
code, resultErr := errorCodeForError(inner)
if code != defaultErrorCode {
return code, resultErr
}
}

switch e := errors.Cause(causeErr).(type) {
switch e := err.(type) {
case K6Error:
return e.Code, e.Message
case *net.DNSError:
Expand Down

0 comments on commit 9fda18e

Please sign in to comment.