Commit Graph

4 Commits (master)

Author SHA1 Message Date
Adrian Perez 614d223910
Revert "Support Go 1.13 error chains in `Cause` (#215)" (#220)
This reverts commit 49f8f61729.
2020-01-14 20:47:44 +01:00
Jay Petacat 49f8f61729 Support Go 1.13 error chains in `Cause` (#215) 2020-01-07 22:33:24 +01:00
Sherlock Holo 6d954f502e feat: support std errors functions (#213)
* feat: support std errors functions

add function `Is`, `As` and `Unwrap`, like std errors, so that we can
continue to use pkg/errors with go1.13 compatibility

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* style: delete useless comments

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* build: update makefile

update makefile to download dependencies before test anything

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* build: fix makefile

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* chore: delete useless comments

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* Restore Makefile

* revert: revert some change

some change are doing by PR #206 and #212 , so I don't need to do it

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* test: add more check for As unit test

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* revert: only support Is As Unwrap for >=go1.13

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* feat(Unwrap): allow <go1.13 can use Unwrap

`Unwrap` just use type assert, it doesn't need go1.13 actually

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* test: add go1.13 errors compatibility check

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>

* refactor(Unwrap): don't allow <go1.13 use Unwrap

If we implement Unwrap ourselves, may create a risk of incompatibility
if Go 1.14 subtly changes its `Unwrap` implementation.
<go1.13 users doesn't have `Is` or `As`, if they want, they will use
xerrors and it also provides `Unwrap`

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>
2020-01-03 12:25:31 +01:00
Jay Petacat 7f95ac13ed Add support for Go 1.13 error chains (#206)
* Add support for Go 1.13 error chains

Go 1.13 adds support for error chains to the standard libary's errors
package. The new standard library functions require an Unwrap method to
be provided by an error type. This change adds a new Unwrap method
(identical to the existing Cause method) to the unexported error types.
2019-11-09 11:23:16 +01:00