Skip to content

Commit a985d34

Browse files
zcheeneild
authored andcommitted
xerrors: Revert "xerrors: redirect to go1.13 primitives for 1.13"
This reverts CL 167577 Reason for revert: errors.Frame and errors.Formatter were removed in CL 176997 Fixes golang/go#32246 Change-Id: I521cc1176311721a18aaf76d4966e945c8453e9d Reviewed-on: https://go-review.googlesource.com/c/xerrors/+/177379 Run-TryBot: Agniva De Sarker <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matt Joiner <[email protected]> Reviewed-by: Damien Neil <[email protected]>
1 parent 3ee3066 commit a985d34

File tree

6 files changed

+10
-99
lines changed

6 files changed

+10
-99
lines changed

adaptor_go1_12.go adaptor.go

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build !go1.13
6-
75
package xerrors
86

97
import (

adaptor_go1_13.go

-55
This file was deleted.

fmt_test.go

+10-19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package xerrors_test
77
import (
88
"fmt"
99
"io"
10+
"os"
1011
"path"
1112
"reflect"
1213
"regexp"
@@ -90,7 +91,7 @@ func TestErrorFormatter(t *testing.T) {
9091
nonascii = &wrapped{"café", nil}
9192
newline = &wrapped{"msg with\nnewline",
9293
&wrapped{"and another\none", nil}}
93-
fallback = &wrapped{"fallback", xerrors.New("file does not exist")}
94+
fallback = &wrapped{"fallback", os.ErrNotExist}
9495
oldAndNew = &wrapped{"new style", formatError("old style")}
9596
framed = &withFrameAndMore{
9697
frame: xerrors.Caller(0),
@@ -105,13 +106,6 @@ func TestErrorFormatter(t *testing.T) {
105106
want string
106107
regexp bool
107108
}{{
108-
err: xerrors.New("foo"),
109-
fmt: "%+v",
110-
want: "foo:" +
111-
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
112-
"\n .+/golang.org/x/xerrors/fmt_test.go:1\\d\\d",
113-
regexp: true,
114-
}, {
115109
err: simple,
116110
fmt: "%s",
117111
want: "simple",
@@ -162,7 +156,7 @@ func TestErrorFormatter(t *testing.T) {
162156
fmt: "%+v",
163157
want: "something:" +
164158
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
165-
"\n .+/fmt_test.go:9\\d" +
159+
"\n .+/fmt_test.go:97" +
166160
"\n something more",
167161
regexp: true,
168162
}, {
@@ -179,10 +173,7 @@ func TestErrorFormatter(t *testing.T) {
179173
// Note: no colon after the last error, as there are no details.
180174
want: "fallback:" +
181175
"\n somefile.go:123" +
182-
"\n - file does not exist:" +
183-
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
184-
"\n .+/golang.org/x/xerrors/fmt_test.go:9\\d",
185-
regexp: true,
176+
"\n - file does not exist",
186177
}, {
187178
err: opaque,
188179
fmt: "%s",
@@ -290,12 +281,12 @@ func TestErrorFormatter(t *testing.T) {
290281
err: simple,
291282
fmt: "%T",
292283
want: "*xerrors_test.wrapped",
293-
// }, {
294-
// // The behavior for this case is different between go1.12 and go1.13.
295-
// err: simple,
296-
// fmt: "%🤪",
297-
// want: "%!🤪(*xerrors_test.wrapped=&{simple <nil>})", // go1.12
298-
// want: "&{%!🤪(string=simple) <nil>}", // go1.13
284+
}, {
285+
err: simple,
286+
fmt: "%🤪",
287+
want: "%!🤪(*xerrors_test.wrapped)",
288+
// For 1.13:
289+
// want: "%!🤪(*xerrors_test.wrapped=&{simple <nil>})",
299290
}, {
300291
err: formatError("use fmt.Formatter"),
301292
fmt: "%#v",

format_go1_12.go format.go

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build !go1.13
6-
75
package xerrors
86

97
// A Formatter formats error messages.

format_go1_13.go

-19
This file was deleted.

frame_go1_12.go frame.go

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build !go1.13
6-
75
package xerrors
86

97
import (

0 commit comments

Comments
 (0)