aboutsummaryrefslogtreecommitdiff
path: root/src/internal/oserror/errors_test.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2019-05-13 16:46:31 -0700
committerDamien Neil <dneil@google.com>2019-05-15 19:53:28 +0000
commit14491a2ec499668388d7fe7e95b84dbf0e1cf04d (patch)
tree9f195103490db8c82c9a01dc7922738b00205ebc /src/internal/oserror/errors_test.go
parent3e2c522d5c712fa2b1d18a101272abefc7dcb074 (diff)
downloadgo-14491a2ec499668388d7fe7e95b84dbf0e1cf04d.tar.xz
fmt: support %w
When fmt.Errorf is provided with a %w verb with an error operand, return an error implementing an Unwrap method returning that operand. It is invalid to use %w with other formatting functions, to use %w multiple times in a format string, or to use %w with a non-error operand. When the Errorf format string contains an invalid use of %w, the returned error does not implement Unwrap. Change-Id: I534e20d3b163ab22c2b137b1c9095906dc243221 Reviewed-on: https://go-review.googlesource.com/c/go/+/176998 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Diffstat (limited to 'src/internal/oserror/errors_test.go')
-rw-r--r--src/internal/oserror/errors_test.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/internal/oserror/errors_test.go b/src/internal/oserror/errors_test.go
index 50dd4678d4..6d6a56a0c7 100644
--- a/src/internal/oserror/errors_test.go
+++ b/src/internal/oserror/errors_test.go
@@ -34,8 +34,7 @@ func TestIsTimeout(t *testing.T) {
{true, ttError{timeout: true}},
{true, isError{os.ErrTimeout}},
{true, os.ErrTimeout},
- // TODO: restore when %w is reimplemented
- //{true, fmt.Errorf("wrap: %w", os.ErrTimeout)},
+ {true, fmt.Errorf("wrap: %w", os.ErrTimeout)},
{false, ttError{timeout: false}},
{false, errors.New("error")},
} {
@@ -53,8 +52,7 @@ func TestIsTemporary(t *testing.T) {
{true, ttError{temporary: true}},
{true, isError{os.ErrTemporary}},
{true, os.ErrTemporary},
- // TODO: restore when %w is reimplemented
- //{true, fmt.Errorf("wrap: %w", os.ErrTemporary)},
+ {true, fmt.Errorf("wrap: %w", os.ErrTemporary)},
{false, ttError{temporary: false}},
{false, errors.New("error")},
} {