aboutsummaryrefslogtreecommitdiff
path: root/src/errors/wrap.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2019-05-13 14:51:55 -0700
committerDamien Neil <dneil@google.com>2019-05-15 19:53:15 +0000
commit3e2c522d5c712fa2b1d18a101272abefc7dcb074 (patch)
treeff30ae55319bd82eb832829a2c65c252d3969abb /src/errors/wrap.go
parent599ec7720fefdb60344bb4a9dab481ed302aa473 (diff)
downloadgo-3e2c522d5c712fa2b1d18a101272abefc7dcb074.tar.xz
errors, fmt: revert rejected changes for Go 1.13
Reverts the following changes: https://go.googlesource.com/go/+/1f90d081391d4f5911960fd28d81d7ea5e554a8f https://go.googlesource.com/go/+/8bf18b56a47a98b9dd2fa03beb358312237a8c76 https://go.googlesource.com/go/+/5402854c3557f87fa2741a52ffc15dfb1ef333cc https://go.googlesource.com/go/+/37f84817247d3b8e687a701ccb0d6bc7ffe3cb78 https://go.googlesource.com/go/+/6be6f114e0d483a233101a67c9644cd72bd3ae7a Partially reverts the followinng change, removing the errors.Opaque function and the errors.Wrapper type definition: https://go.googlesource.com/go/+/62f5e8156ef56fa61e6af56f4ccc633bde1a9120 Updates documentation referencing the Wrapper type. Change-Id: Ia622883e39cafb06809853e3fd90b21441124534 Reviewed-on: https://go-review.googlesource.com/c/go/+/176997 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Diffstat (limited to 'src/errors/wrap.go')
-rw-r--r--src/errors/wrap.go29
1 files changed, 3 insertions, 26 deletions
diff --git a/src/errors/wrap.go b/src/errors/wrap.go
index b53caa6fc9..62332b1a88 100644
--- a/src/errors/wrap.go
+++ b/src/errors/wrap.go
@@ -8,35 +8,12 @@ import (
"internal/reflectlite"
)
-// A Wrapper provides context around another error.
-type Wrapper interface {
- // Unwrap returns the next error in the error chain.
- // If there is no next error, Unwrap returns nil.
- Unwrap() error
-}
-
-// Opaque returns an error with the same error formatting as err
-// but that does not match err and cannot be unwrapped.
-func Opaque(err error) error {
- return noWrapper{err}
-}
-
-type noWrapper struct {
- error
-}
-
-func (e noWrapper) FormatError(p Printer) (next error) {
- if f, ok := e.error.(Formatter); ok {
- return f.FormatError(p)
- }
- p.Print(e.error)
- return nil
-}
-
// Unwrap returns the result of calling the Unwrap method on err, if err
// implements Wrapper. Otherwise, Unwrap returns nil.
func Unwrap(err error) error {
- u, ok := err.(Wrapper)
+ u, ok := err.(interface {
+ Unwrap() error
+ })
if !ok {
return nil
}