Skip to content

Commit

Permalink
xerrors: Revert "xerrors: redirect to go1.13 primitives for 1.13"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
zchee authored and neild committed Jul 17, 2019
1 parent 3ee3066 commit a985d34
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 99 deletions.
2 changes: 0 additions & 2 deletions adaptor_go1_12.go → adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !go1.13

package xerrors

import (
Expand Down
55 changes: 0 additions & 55 deletions adaptor_go1_13.go

This file was deleted.

29 changes: 10 additions & 19 deletions fmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package xerrors_test
import (
"fmt"
"io"
"os"
"path"
"reflect"
"regexp"
Expand Down Expand Up @@ -90,7 +91,7 @@ func TestErrorFormatter(t *testing.T) {
nonascii = &wrapped{"café", nil}
newline = &wrapped{"msg with\nnewline",
&wrapped{"and another\none", nil}}
fallback = &wrapped{"fallback", xerrors.New("file does not exist")}
fallback = &wrapped{"fallback", os.ErrNotExist}
oldAndNew = &wrapped{"new style", formatError("old style")}
framed = &withFrameAndMore{
frame: xerrors.Caller(0),
Expand All @@ -105,13 +106,6 @@ func TestErrorFormatter(t *testing.T) {
want string
regexp bool
}{{
err: xerrors.New("foo"),
fmt: "%+v",
want: "foo:" +
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
"\n .+/golang.org/x/xerrors/fmt_test.go:1\\d\\d",
regexp: true,
}, {
err: simple,
fmt: "%s",
want: "simple",
Expand Down Expand Up @@ -162,7 +156,7 @@ func TestErrorFormatter(t *testing.T) {
fmt: "%+v",
want: "something:" +
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
"\n .+/fmt_test.go:9\\d" +
"\n .+/fmt_test.go:97" +
"\n something more",
regexp: true,
}, {
Expand All @@ -179,10 +173,7 @@ func TestErrorFormatter(t *testing.T) {
// Note: no colon after the last error, as there are no details.
want: "fallback:" +
"\n somefile.go:123" +
"\n - file does not exist:" +
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
"\n .+/golang.org/x/xerrors/fmt_test.go:9\\d",
regexp: true,
"\n - file does not exist",
}, {
err: opaque,
fmt: "%s",
Expand Down Expand Up @@ -290,12 +281,12 @@ func TestErrorFormatter(t *testing.T) {
err: simple,
fmt: "%T",
want: "*xerrors_test.wrapped",
// }, {
// // The behavior for this case is different between go1.12 and go1.13.
// err: simple,
// fmt: "%🤪",
// want: "%!🤪(*xerrors_test.wrapped=&{simple <nil>})", // go1.12
// want: "&{%!🤪(string=simple) <nil>}", // go1.13
}, {
err: simple,
fmt: "%🤪",
want: "%!🤪(*xerrors_test.wrapped)",
// For 1.13:
// want: "%!🤪(*xerrors_test.wrapped=&{simple <nil>})",
}, {
err: formatError("use fmt.Formatter"),
fmt: "%#v",
Expand Down
2 changes: 0 additions & 2 deletions format_go1_12.go → format.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !go1.13

package xerrors

// A Formatter formats error messages.
Expand Down
19 changes: 0 additions & 19 deletions format_go1_13.go

This file was deleted.

2 changes: 0 additions & 2 deletions frame_go1_12.go → frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !go1.13

package xerrors

import (
Expand Down

0 comments on commit a985d34

Please sign in to comment.