Repository: dragonflyoss/Dragonfly2
Pull request #380 (2021-06-29 08:11:13)

Goreleaser added mockgen
<!--- Provide a general summary of your changes in the Title above -->

## Description
Goreleaser added mockgen.
<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation Update (if none of the other choices apply)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] Code compiles correctly.
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.


codecov-commenter: # [Codecov](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) Report
> Merging [#380](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) (806914a) into [main](https://codecov.io/gh/dragonflyoss/Dragonfly2/commit/d2e9414b0445dae657a76571d2dc349b0e0af086?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) (d2e9414) will **decrease** coverage by `0.06%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380/graphs/tree.svg?width=650&height=150&src=pr&token=PUICJYSAT7&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss)](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss)

```diff
@@            Coverage Diff             @@
##             main     #380      +/-   ##
==========================================
- Coverage   42.22%   42.16%   -0.07%     
==========================================
  Files          74       73       -1     
  Lines        5643     5640       -3     
==========================================
- Hits         2383     2378       -5     
- Misses       2914     2915       +1     
- Partials      346      347       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `42.16% <ø> (-0.07%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) | Coverage Δ | |
|---|---|---|
| [pkg/util/net/iputils/ip\_utils.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-cGtnL3V0aWwvbmV0L2lwdXRpbHMvaXBfdXRpbHMuZ28=) | `61.22% <0.00%> (-4.09%)` | :arrow_down: |
| [client/daemon/peer/peertask\_base.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX2Jhc2UuZ28=) | `32.76% <0.00%> (-0.73%)` | :arrow_down: |
| [client/daemon/peerhost\_stub.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/380/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyaG9zdF9zdHViLmdv) | | |


Patch:
diff --git a/.goreleaser.yml b/.goreleaser.yml
index cbd9c411..21c9bcfd 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -1,7 +1,7 @@
 before:
   hooks:
     - go mod download
-    - go install github.com/golang/mock/mockgen@v1.6.0
+    - go get github.com/golang/mock/mockgen@v1.6.0
     - go generate ./...
 
 builds:
diff --git a/cdnsystem/daemon/cdn/cache_detector.go b/cdnsystem/daemon/cdn/cache_detector.go
index c4b7258e..aff489de 100644
--- a/cdnsystem/daemon/cdn/cache_detector.go
+++ b/cdnsystem/daemon/cdn/cache_detector.go
@@ -89,7 +89,7 @@ func (cd *cacheDetector) doDetect(task *types.SeedTask, fileMd5 hash.Hash) (resu
 		return nil, errors.Wrapf(err, "read file meta data of task %s", task.TaskID)
 	}
 	if err := checkSameFile(task, fileMetaData); err != nil {
-		return nil, errors.Wrapf(err, "task does not match meta information of task file")
+		return nil, errors.Wrapf(err, "check same file")
 	}
 	ctx, expireCancel := context.WithTimeout(context.Background(), 4*time.Second)
 	defer expireCancel()
@@ -100,8 +100,7 @@ func (cd *cacheDetector) doDetect(task *types.SeedTask, fileMd5 hash.Hash) (resu
 	}
 	logger.WithTaskID(task.TaskID).Debugf("task expired result: %t", expired)
 	if expired {
-		return nil, errors.Wrapf(cdnerrors.ErrResourceExpired, "url:%s, expireInfo:%+v", task.URL,
-			fileMetaData.ExpireInfo)
+		return nil, cdnerrors.ErrResourceExpired{URL: task.URL}
 	}
 	// not expired
 	if fileMetaData.Finish {
@@ -117,7 +116,7 @@ func (cd *cacheDetector) doDetect(task *types.SeedTask, fileMd5 hash.Hash) (resu
 		return nil, errors.Wrapf(err, "check if url(%s) supports range request", task.URL)
 	}
 	if !supportRange {
-		return nil, errors.Wrapf(cdnerrors.ErrResourceNotSupportRangeRequest, "url:%s", task.URL)
+		return nil, cdnerrors.ErrResourceNotSupportRangeRequest{URL: task.URL}
 	}
 	return cd.parseByReadFile(task.TaskID, fileMetaData, fileMd5)
 }
@@ -125,15 +124,15 @@ func (cd *cacheDetector) doDetect(task *types.SeedTask, fileMd5 hash.Hash) (resu
 // parseByReadMetaFile detect cache by read meta and pieceMeta files of task
 func (cd *cacheDetector) parseByReadMetaFile(taskID string, fileMetaData *storage.FileMetaData) (*cacheResult, error) {
 	if !fileMetaData.Success {
-		return nil, errors.Wrapf(cdnerrors.ErrDownloadFail, "success flag of download is false")
+		return nil, fmt.Errorf("success flag of taskID %s is false", taskID)
 	}
 	pieceMetaRecords, err := cd.cacheDataManager.readAndCheckPieceMetaRecords(taskID, fileMetaData.PieceMd5Sign)
 	if err != nil {
 		return nil, errors.Wrapf(err, "check piece meta integrity")
 	}
 	if fileMetaData.TotalPieceCount > 0 && len(pieceMetaRecords) != int(fileMetaData.TotalPieceCount) {
-		return nil, errors.Wrapf(cdnerrors.ErrPieceCountNotEqual, "piece file piece count(%d), "+
-			"meta file piece count(%d)", len(pieceMetaRecords), fileMetaData.TotalPieceCount)
+		err := cdnerrors.ErrInconsistentValues{Expected: fileMetaData.TotalPieceCount, Actual: len(pieceMetaRecords)}
+		return nil, errors.Wrapf(err, "compare file piece count")
 	}
 	storageInfo, err := cd.cacheDataManager.statDownloadFile(taskID)
 	if err != nil {
@@ -141,8 +140,11 @@ func (cd *cacheDetector) parseByReadMetaFile(taskID string, fileMetaData *storag
 	}
 	// check file data integrity by file size
 	if fileMetaData.CdnFileLength != storageInfo.Size {
-		return nil, errors.Wrapf(cdnerrors.ErrFileLengthNotEqual, "meta size %d, storage size %d",
-			fileMetaData.CdnFileLength, storageInfo.Size)
+		err := cdnerrors.ErrInconsistentValues{
+			Expected: fileMetaData.CdnFileLength,
+			Actual:   storageInfo.Size,
+		}
+		return nil, errors.Wrapf(err, "compare file cdn file length")
 	}
 	return &cacheResult{
 		breakPoint:       -1,
@@ -249,13 +251,16 @@ func checkPieceContent(reader io.Reader, pieceRecord *storage.PieceMetaRecord, f
 	pieceMd5 := md5.New()
 	tee := io.TeeReader(io.TeeReader(io.LimitReader(reader, int64(pieceRecord.PieceLen)), pieceMd5), fileMd5)
 	if n, err := io.Copy(ioutil.Discard, tee); n != int64(pieceRecord.PieceLen) || err != nil {
-		return fmt.Errorf("read piece content: %v", err)
+		return errors.Wrap(err, "read piece content")
 	}
 	realPieceMd5 := digestutils.ToHashString(pieceMd5)
 	// check piece content
 	if realPieceMd5 != pieceRecord.Md5 {
-		return errors.Wrapf(cdnerrors.ErrPieceMd5NotMatch, "realPieceMd5 md5 (%s), expected md5 (%s)",
-			realPieceMd5, pieceRecord.Md5)
+		err := cdnerrors.ErrInconsistentValues{
+			Expected: pieceRecord.Md5,
+			Actual:   realPieceMd5,
+		}
+		return errors.Wrap(err, "compare piece md5")
 	}
 	return nil
 }
diff --git a/cdnsystem/daemon/cdn/cache_writer.go b/cdnsystem/daemon/cdn/cache_writer.go
index 60eed651..6b44ae7f 100644
--- a/cdnsystem/daemon/cdn/cache_writer.go
+++ b/cdnsystem/daemon/cdn/cache_writer.go
@@ -75,12 +75,12 @@ func (cw *cacheWriter) startWriter(reader io.Reader, task *types.SeedTask, detec
 	}
 	storageInfo, err := cw.cacheDataManager.statDownloadFile(task.TaskID)
 	if err != nil {
-		return &downloadMetadata{backSourceLength: backSourceFileLength}, fmt.Errorf("stat cdn download file: %v", storageInfo)
+		return &downloadMetadata{backSourceLength: backSourceFileLength}, fmt.Errorf("stat cdn download file: %v", err)
 	}
 	// todo Try getting it from the ProgressManager first
 	pieceMd5Sign, _, err := cw.cacheDataManager.getPieceMd5Sign(task.TaskID)
 	if err != nil {
-		return &downloadMetadata{backSourceLength: backSourceFileLength}, fmt.Errorf("get piece md5 sign: %v", pieceMd5Sign)
+		return &downloadMetadata{backSourceLength: backSourceFileLength}, fmt.Errorf("get piece md5 sign: %v", err)
 	}
 	return &downloadMetadata{
 		backSourceLength:     backSourceFileLength,
@@ -111,6 +111,9 @@ func (cw *cacheWriter) doWrite(reader io.Reader, task *types.SeedTask, routineCo
 			close(jobCh)
 			return backSourceFileLength, 0, fmt.Errorf("read source taskID %s pieceNum %d piece: %v", task.TaskID, curPieceNum, err)
 		}
+		if n == 0 {
+			break
+		}
 		backSourceFileLength = backSourceFileLength + n
 
 		jobCh <- &piece{
diff --git a/cdnsystem/daemon/task/manager_util.go b/cdnsystem/daemon/task/manager_util.go
index 82debd94..a4a1395e 100644
--- a/cdnsystem/daemon/task/manager_util.go
+++ b/cdnsystem/daemon/task/manager_util.go
@@ -48,8 +48,8 @@ func (tm *Manager) addOrUpdateTask(ctx context.Context, request *types.TaskRegis
 	if key, err := tm.taskURLUnReachableStore.Get(taskID); err == nil {
 		if unReachableStartTime, ok := key.(time.Time); ok &&
 			time.Since(unReachableStartTime) < tm.cfg.FailAccessInterval {
-			return nil, cdnerrors.ErrURLNotReachable{URL: request.URL, Cause: fmt.Errorf("task hit unReachable cache and interval less than %d, url: %s",
-				tm.cfg.FailAccessInterval, request.URL)}
+			return nil, errors.Wrapf(cdnerrors.ErrURLNotReachable{URL: request.URL}, "task hit unReachable cache and interval less than %d, "+
+				"url: %s", tm.cfg.FailAccessInterval, request.URL)
 		}
 		tm.taskURLUnReachableStore.Delete(taskID)
 		logger.Debugf("delete taskID:%s from url unReachable store", taskID)
diff --git a/cdnsystem/errors/errors.go b/cdnsystem/errors/errors.go
index fe08e282..0de97f0e 100644
--- a/cdnsystem/errors/errors.go
+++ b/cdnsystem/errors/errors.go
@@ -24,12 +24,11 @@ import (
 
 // ErrURLNotReachable represents the url is a not reachable.
 type ErrURLNotReachable struct {
-	URL   string
-	Cause error
+	URL string
 }
 
 func (e ErrURLNotReachable) Error() string {
-	return fmt.Sprintf("url %s not reachable: %v", e.URL, e.Cause)
+	return fmt.Sprintf("url %s not reachable", e.URL)
 }
 
 // ErrTaskIDDuplicate represents the task id is in conflict.
@@ -42,42 +41,57 @@ func (e ErrTaskIDDuplicate) Error() string {
 	return fmt.Sprintf("taskId %s conflict: %v", e.TaskID, e.Cause)
 }
 
-var (
-	// ErrSystemError represents the error is a system error.
-	ErrSystemError = errors.New("system error")
+type ErrInconsistentValues struct {
+	Expected interface{}
+	Actual   interface{}
+}
 
-	// ErrPieceCountNotEqual represents the number of pieces downloaded does not match the amount of meta information
-	ErrPieceCountNotEqual = errors.New("inconsistent number of pieces")
+func (e ErrInconsistentValues) Error() string {
+	return fmt.Sprintf("inconsistent number of pieces, expected %s, actual: %s", e.Expected, e.Actual)
+}
 
-	// ErrFileLengthNotEqual represents the file length of downloaded dose not match the length of meta information
-	ErrFileLengthNotEqual = errors.New("inconsistent file length")
+// ErrResourceExpired represents the downloaded resource has expired
+type ErrResourceExpired struct {
+	URL string
+}
 
-	// ErrDownloadFail represents an exception was encountered while downloading the file
-	ErrDownloadFail = errors.New("resource download failed")
+func (e ErrResourceExpired) Error() string {
+	return fmt.Sprintf("url %s expired", e.URL)
+}
 
-	// ErrResourceExpired represents the downloaded resource has expired
-	ErrResourceExpired = errors.New("resource expired")
+// ErrResourceNotSupportRangeRequest represents the downloaded resource does not support Range downloads
+type ErrResourceNotSupportRangeRequest struct {
+	URL string
+}
 
-	// ErrResourceNotSupportRangeRequest represents the downloaded resource does not support Range downloads
-	ErrResourceNotSupportRangeRequest = errors.New("resource does not support range request")
+func (e ErrResourceNotSupportRangeRequest) Error() string {
+	return fmt.Sprintf("url %s does not support range request", e.URL)
+}
+
+// ErrFileNotExist represents the file is not exists
+type ErrFileNotExist struct {
+	File string
+}
+
+func (e ErrFileNotExist) Error() string {
+	return fmt.Sprintf("file or dir %s not exist", e.File)
+}
+
+var (
+	// ErrSystemError represents the error is a system error.
+	ErrSystemError = errors.New("system error")
 
-	// ErrPieceMd5NotMatch represents the MD5 value of the download file is inconsistent with the meta information
-	ErrPieceMd5NotMatch = errors.New("piece md5 check fail")
+	// ErrTaskDownloadFail represents an exception was encountered while downloading the file
+	ErrTaskDownloadFail = errors.New("resource download failed")
 
 	// ErrDataNotFound represents the data cannot be found.
 	ErrDataNotFound = errors.New("data not found")
 
-	// ErrFileNotExist represents the file is not exists
-	ErrFileNotExist = errors.New("file or directory not exist")
-
 	// ErrInvalidValue represents the value is invalid.
 	ErrInvalidValue = errors.New("invalid value")
 
 	// ErrConvertFailed represents failed to convert.
 	ErrConvertFailed = errors.New("convert failed")
-
-	// ErrRangeNotSatisfiable represents the length of file is insufficient.
-	ErrRangeNotSatisfiable = errors.New("range not satisfiable")
 )
 
 // IsSystemError checks the error is a system error or not.
@@ -99,28 +113,26 @@ func IsTaskIDDuplicate(err error) bool {
 	return ok
 }
 
-func IsPieceCountNotEqual(err error) bool {
-	return errors.Cause(err) == ErrPieceCountNotEqual
-}
-
-func IsFileLengthNotEqual(err error) bool {
-	return errors.Cause(err) == ErrFileLengthNotEqual
+func IsInconsistentValues(err error) bool {
+	err = errors.Cause(err)
+	_, ok := err.(ErrInconsistentValues)
+	return ok
 }
 
 func IsDownloadFail(err error) bool {
-	return errors.Cause(err) == ErrDownloadFail
+	return errors.Cause(err) == ErrTaskDownloadFail
 }
 
 func IsResourceExpired(err error) bool {
-	return errors.Cause(err) == ErrResourceExpired
+	err = errors.Cause(err)
+	_, ok := err.(ErrResourceExpired)
+	return ok
 }
 
 func IsResourceNotSupportRangeRequest(err error) bool {
-	return errors.Cause(err) == ErrResourceNotSupportRangeRequest
-}
-
-func IsPieceMd5NotMatch(err error) bool {
-	return errors.Cause(err) == ErrPieceMd5NotMatch
+	err = errors.Cause(err)
+	_, ok := err.(ErrResourceNotSupportRangeRequest)
+	return ok
 }
 
 func IsDataNotFound(err error) bool {
@@ -135,10 +147,8 @@ func IsConvertFailed(err error) bool {
 	return errors.Cause(err) == ErrConvertFailed
 }
 
-func IsRangeNotSatisfiable(err error) bool {
-	return errors.Cause(err) == ErrRangeNotSatisfiable
-}
-
 func IsFileNotExist(err error) bool {
-	return errors.Cause(err) == ErrFileNotExist
+	err = errors.Cause(err)
+	_, ok := err.(ErrFileNotExist)
+	return ok
 }
diff --git a/cdnsystem/storedriver/local/local_driver.go b/cdnsystem/storedriver/local/local_driver.go
index 9955422d..ea65930e 100644
--- a/cdnsystem/storedriver/local/local_driver.go
+++ b/cdnsystem/storedriver/local/local_driver.go
@@ -30,7 +30,6 @@ import (
 	"d7y.io/dragonfly/v2/pkg/unit"
 	"d7y.io/dragonfly/v2/pkg/util/fileutils"
 	"d7y.io/dragonfly/v2/pkg/util/statutils"
-	"github.com/pkg/errors"
 )
 
 // Ensure driver implements the storedriver.Driver interface
@@ -368,7 +367,7 @@ func (ds *driver) statPath(bucket, key string) (string, os.FileInfo, error) {
 	f, err := os.Stat(filePath)
 	if err != nil {
 		if os.IsNotExist(err) {
-			return "", nil, errors.Wrapf(cdnerrors.ErrFileNotExist, "no such file or directory:%s exists", filePath)
+			return "", nil, cdnerrors.ErrFileNotExist{File: "filePath"}
 		}
 		return "", nil, err
 	}
diff --git a/go.mod b/go.mod
index 15a03c98..ea70890f 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@ require (
 	github.com/go-redis/redis/v8 v8.10.0
 	github.com/gofrs/flock v0.8.0
 	github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
-	github.com/golang/mock v1.5.0
+	github.com/golang/mock v1.6.0
 	github.com/golang/protobuf v1.4.3
 	github.com/google/uuid v1.1.5
 	github.com/gorilla/mux v1.7.3
@@ -52,7 +52,7 @@ require (
 	go.uber.org/zap v1.16.0
 	golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
 	golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
-	golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
+	golang.org/x/sys v0.0.0-20210510120138-977fb7262007
 	golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
 	golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
 	google.golang.org/grpc v1.36.0
diff --git a/go.sum b/go.sum
index 6235acfd..98fbb2ee 100644
--- a/go.sum
+++ b/go.sum
@@ -57,12 +57,9 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
 github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
-github.com/coreos/etcd v3.3.13+incompatible h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ=
 github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
-github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
-github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
@@ -169,8 +166,8 @@ github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4er
 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
-github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
-github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
+github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
+github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -450,6 +447,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
 github.com/xo/dburl v0.7.0 h1:sGcxE2sefO6yJwX99EDzZCU0AACvWUKEqT4eIHFDPmY=
 github.com/xo/dburl v0.7.0/go.mod h1:W68zXnBfTb4zcKLI1yEYRyYIQjcjoyCRn4YMD/QzcpE=
 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg=
 github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
 go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
@@ -514,10 +512,10 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG
 golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
 golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
 golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449 h1:xUIPaMhvROX9dhPvRCenIJtU78+lbEenGbgqB5hfHCQ=
 golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -543,8 +541,9 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
 golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -587,8 +586,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
-golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
 golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -630,10 +630,10 @@ golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtn
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e h1:t96dS3DO8DGjawSLJL/HIdz8CycAd2v07XxqB3UPTi0=
 golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE=
 golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
+golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/pkg/source/httpprotocol/http_source_client.go b/pkg/source/httpprotocol/http_source_client.go
index c74da521..485e0e08 100644
--- a/pkg/source/httpprotocol/http_source_client.go
+++ b/pkg/source/httpprotocol/http_source_client.go
@@ -24,7 +24,6 @@ import (
 	"net/http"
 	"time"
 
-	cdnerrors "d7y.io/dragonfly/v2/cdnsystem/errors"
 	"d7y.io/dragonfly/v2/pkg/source"
 	"d7y.io/dragonfly/v2/pkg/structure/maputils"
 	"d7y.io/dragonfly/v2/pkg/util/stringutils"
@@ -81,13 +80,13 @@ func WithHTTPClient(client *http.Client) HTTPSourceClientOption {
 func (client *httpSourceClient) GetContentLength(ctx context.Context, url string, header source.RequestHeader) (int64, error) {
 	resp, err := client.doRequest(ctx, http.MethodGet, url, header)
 	if err != nil {
-		return -1, cdnerrors.ErrURLNotReachable{URL: url, Cause: err}
+		return -1, err
 	}
 	resp.Body.Close()
 	// todo Here if other status codes should be added to ErrURLNotReachable, if not, it will be downloaded frequently for 404 or 403
 	if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
 		// todo Whether this situation should be distinguished from the err situation, similar to proposing another error type to indicate that this  error can interact with the URL, but the status code does not meet expectations
-		return -1, cdnerrors.ErrURLNotReachable{URL: url, Cause: fmt.Errorf("get http resource length failed, unexpected code: %d", resp.StatusCode)}
+		return -1, fmt.Errorf("get http resource length failed, unexpected code: %d", resp.StatusCode)
 	}
 	return resp.ContentLength, nil
 }
diff --git a/pkg/source/ossprotocol/oss_source_client.go b/pkg/source/ossprotocol/oss_source_client.go
index 20a77093..5775a63f 100644
--- a/pkg/source/ossprotocol/oss_source_client.go
+++ b/pkg/source/ossprotocol/oss_source_client.go
@@ -178,19 +178,19 @@ func (osc *ossSourceClient) getMeta(ctx context.Context, url string, header map[
 	}
 	ossObject, err := parseOssObject(url)
 	if err != nil {
-		return nil, cdnerrors.ErrURLNotReachable{URL: url, Cause: fmt.Errorf("parse oss object: %v", err)}
+		return nil, errors.Wrapf(err, "parse oss object")
 	}
 
 	bucket, err := client.Bucket(ossObject.bucket)
 	if err != nil {
-		return nil, cdnerrors.ErrURLNotReachable{URL: url, Cause: fmt.Errorf("get bucket:%s: %v", ossObject.bucket, err)}
+		return nil, errors.Wrapf(err, "get bucket:%s", ossObject.bucket)
 	}
 	isExist, err := bucket.IsObjectExist(ossObject.object)
 	if err != nil {
-		return nil, cdnerrors.ErrURLNotReachable{URL: url, Cause: fmt.Errorf("prob object:%s exist: %v", ossObject.object, err)}
+		return nil, errors.Wrapf(err, "prob object:%s if exist", ossObject.object)
 	}
 	if !isExist {
-		return nil, cdnerrors.ErrURLNotReachable{URL: url, Cause: fmt.Errorf("oss object:%s does not exist", ossObject.object)}
+		return nil, fmt.Errorf("oss object:%s does not exist", ossObject.object)
 	}
 	return bucket.GetObjectMeta(ossObject.object, getOptions(header)...)
 }


Test patch:
diff --git a/cdnsystem/daemon/cdn/cache_detector_test.go b/cdnsystem/daemon/cdn/cache_detector_test.go
index 1f02878a..24ef6bcf 100644
--- a/cdnsystem/daemon/cdn/cache_detector_test.go
+++ b/cdnsystem/daemon/cdn/cache_detector_test.go
@@ -59,7 +59,7 @@ func (suite *CacheDetectorTestSuite) SetupSuite() {
 	storageMgr.EXPECT().ReadFileMetaData(fullNoExpiredCache.taskID).Return(fullNoExpiredCache.fileMeta, nil).AnyTimes()
 	storageMgr.EXPECT().ReadFileMetaData(partialNotSupportRangeCache.taskID).Return(partialNotSupportRangeCache.fileMeta, nil).AnyTimes()
 	storageMgr.EXPECT().ReadFileMetaData(partialSupportRangeCache.taskID).Return(partialSupportRangeCache.fileMeta, nil).AnyTimes()
-	storageMgr.EXPECT().ReadFileMetaData(noCache.taskID).Return(noCache.fileMeta, cdnerrors.ErrFileNotExist).AnyTimes()
+	storageMgr.EXPECT().ReadFileMetaData(noCache.taskID).Return(noCache.fileMeta, cdnerrors.ErrFileNotExist{}).AnyTimes()
 	storageMgr.EXPECT().ReadDownloadFile(fullNoExpiredCache.taskID).DoAndReturn(
 		func(taskID string) (io.ReadCloser, error) {
 			content, err := ioutil.ReadFile("../../testdata/cdn/go.html")
@@ -78,11 +78,11 @@ func (suite *CacheDetectorTestSuite) SetupSuite() {
 			suite.Nil(err)
 			return ioutil.NopCloser(strings.NewReader(string(content))), nil
 		}).AnyTimes()
-	storageMgr.EXPECT().ReadDownloadFile(noCache.taskID).Return(nil, cdnerrors.ErrFileNotExist).AnyTimes()
+	storageMgr.EXPECT().ReadDownloadFile(noCache.taskID).Return(nil, cdnerrors.ErrFileNotExist{}).AnyTimes()
 	storageMgr.EXPECT().ReadPieceMetaRecords(fullNoExpiredCache.taskID).Return(fullNoExpiredCache.pieces, nil).AnyTimes()
 	storageMgr.EXPECT().ReadPieceMetaRecords(partialNotSupportRangeCache.taskID).Return(partialNotSupportRangeCache.pieces, nil).AnyTimes()
 	storageMgr.EXPECT().ReadPieceMetaRecords(partialSupportRangeCache.taskID).Return(partialSupportRangeCache.pieces, nil).AnyTimes()
-	storageMgr.EXPECT().ReadPieceMetaRecords(noCache.taskID).Return(nil, cdnerrors.ErrFileNotExist).AnyTimes()
+	storageMgr.EXPECT().ReadPieceMetaRecords(noCache.taskID).Return(nil, cdnerrors.ErrFileNotExist{}).AnyTimes()
 	storageMgr.EXPECT().StatDownloadFile(fullNoExpiredCache.taskID).Return(&storedriver.StorageInfo{
 		Path:       "",
 		Size:       9789,
diff --git a/cdnsystem/errors/errors_test.go b/cdnsystem/errors/errors_test.go
index fb6a14b7..aa888868 100644
--- a/cdnsystem/errors/errors_test.go
+++ b/cdnsystem/errors/errors_test.go
@@ -116,13 +116,13 @@ func (s *ErrorTestSuite) TestIsDownloadFail() {
 		{
 			name: "equal",
 			args: args{
-				err: ErrDownloadFail,
+				err: ErrTaskDownloadFail,
 			},
 			want: true,
 		}, {
 			name: "wrap",
 			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrDownloadFail, "wrap err"), "wapp err"),
+				err: errors.Wrapf(errors.Wrapf(ErrTaskDownloadFail, "wrap err"), "wapp err"),
 			},
 			want: true,
 		}, {
@@ -140,42 +140,6 @@ func (s *ErrorTestSuite) TestIsDownloadFail() {
 	}
 }
 
-func (s *ErrorTestSuite) TestIsFileLengthNotEqual() {
-	type args struct {
-		err error
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		{
-			name: "equal",
-			args: args{
-				err: ErrFileLengthNotEqual,
-			},
-			want: true,
-		}, {
-			name: "wrap",
-			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrFileLengthNotEqual, "wrap err"), "wapp err"),
-			},
-			want: true,
-		}, {
-			name: "notEqual",
-			args: args{
-				err: errors.Wrapf(ErrInvalidValue, "invaid"),
-			},
-			want: false,
-		},
-	}
-	for _, tt := range tests {
-		s.Run(tt.name, func() {
-			s.Equal(tt.want, IsFileLengthNotEqual(tt.args.err))
-		})
-	}
-}
-
 func (s *ErrorTestSuite) TestIsFileNotExist() {
 	type args struct {
 		err error
@@ -188,13 +152,13 @@ func (s *ErrorTestSuite) TestIsFileNotExist() {
 		{
 			name: "equal",
 			args: args{
-				err: ErrFileNotExist,
+				err: ErrFileNotExist{},
 			},
 			want: true,
 		}, {
 			name: "wrap",
 			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrFileNotExist, "wrap err"), "wapp err"),
+				err: errors.Wrapf(errors.Wrapf(ErrFileNotExist{}, "wrap err"), "wapp err"),
 			},
 			want: true,
 		}, {
@@ -248,79 +212,7 @@ func (s *ErrorTestSuite) TestIsInvalidValue() {
 	}
 }
 
-func (s *ErrorTestSuite) TestIsPieceCountNotEqual() {
-	type args struct {
-		err error
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		{
-			name: "equal",
-			args: args{
-				err: ErrPieceCountNotEqual,
-			},
-			want: true,
-		}, {
-			name: "wrap",
-			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrPieceCountNotEqual, "wrap err"), "wapp err"),
-			},
-			want: true,
-		}, {
-			name: "notEqual",
-			args: args{
-				err: errors.Wrapf(ErrInvalidValue, "invaid"),
-			},
-			want: false,
-		},
-	}
-	for _, tt := range tests {
-		s.Run(tt.name, func() {
-			s.Equal(tt.want, IsPieceCountNotEqual(tt.args.err))
-		})
-	}
-}
-
-func (s *ErrorTestSuite) TestIsPieceMd5NotMatch() {
-	type args struct {
-		err error
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		{
-			name: "equal",
-			args: args{
-				err: ErrPieceMd5NotMatch,
-			},
-			want: true,
-		}, {
-			name: "wrap",
-			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrPieceMd5NotMatch, "wrap err"), "wapp err"),
-			},
-			want: true,
-		}, {
-			name: "notEqual",
-			args: args{
-				err: errors.Wrapf(ErrInvalidValue, "invaid"),
-			},
-			want: false,
-		},
-	}
-	for _, tt := range tests {
-		s.Run(tt.name, func() {
-			s.Equal(tt.want, IsPieceMd5NotMatch(tt.args.err))
-		})
-	}
-}
-
-func (s *ErrorTestSuite) TestIsRangeNotSatisfiable() {
+func (s *ErrorTestSuite) TestIsInconsistentValues() {
 	type args struct {
 		err error
 	}
@@ -332,13 +224,13 @@ func (s *ErrorTestSuite) TestIsRangeNotSatisfiable() {
 		{
 			name: "equal",
 			args: args{
-				err: ErrRangeNotSatisfiable,
+				err: ErrInconsistentValues{},
 			},
 			want: true,
 		}, {
 			name: "wrap",
 			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrRangeNotSatisfiable, "wrap err"), "wapp err"),
+				err: errors.Wrapf(errors.Wrapf(ErrInconsistentValues{}, "wrap err"), "wapp err"),
 			},
 			want: true,
 		}, {
@@ -351,7 +243,7 @@ func (s *ErrorTestSuite) TestIsRangeNotSatisfiable() {
 	}
 	for _, tt := range tests {
 		s.Run(tt.name, func() {
-			s.Equal(tt.want, IsRangeNotSatisfiable(tt.args.err))
+			s.Equal(tt.want, IsInconsistentValues(tt.args.err))
 		})
 	}
 }
@@ -368,13 +260,13 @@ func (s *ErrorTestSuite) TestIsResourceExpired() {
 		{
 			name: "equal",
 			args: args{
-				err: ErrResourceExpired,
+				err: ErrResourceExpired{},
 			},
 			want: true,
 		}, {
 			name: "wrap",
 			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrResourceExpired, "wrap err"), "wapp err"),
+				err: errors.Wrapf(errors.Wrapf(ErrResourceExpired{}, "wrap err"), "wapp err"),
 			},
 			want: true,
 		}, {
@@ -404,13 +296,13 @@ func (s *ErrorTestSuite) TestIsResourceNotSupportRangeRequest() {
 		{
 			name: "equal",
 			args: args{
-				err: ErrResourceNotSupportRangeRequest,
+				err: ErrResourceNotSupportRangeRequest{},
 			},
 			want: true,
 		}, {
 			name: "wrap",
 			args: args{
-				err: errors.Wrapf(errors.Wrapf(ErrResourceNotSupportRangeRequest, "wrap err"), "wapp err"),
+				err: errors.Wrapf(errors.Wrapf(ErrResourceNotSupportRangeRequest{}, "wrap err"), "wapp err"),
 			},
 			want: true,
 		}, {
@@ -518,8 +410,7 @@ func (s *ErrorTestSuite) TestIsURLNotReachable() {
 			name: "equal",
 			args: args{
 				err: ErrURLNotReachable{
-					URL:   "test",
-					Cause: fmt.Errorf("test"),
+					URL: "test",
 				},
 			},
 			want: true,
@@ -527,8 +418,7 @@ func (s *ErrorTestSuite) TestIsURLNotReachable() {
 			name: "wrap",
 			args: args{
 				err: errors.Wrapf(ErrURLNotReachable{
-					URL:   "test",
-					Cause: fmt.Errorf("test"),
+					URL: "test",
 				}, "wapp err"),
 			},
 			want: true,