1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 "golang.org/x/xerrors"
13 type MyError2 struct {
18 func (m *MyError2) Error() string {
22 func (m *MyError2) Format(f fmt.State, c rune) { // implements fmt.Formatter
23 xerrors.FormatError(m, f, c)
26 func (m *MyError2) FormatError(p xerrors.Printer) error { // implements xerrors.Formatter
34 func ExampleFormatError() {
35 err := &MyError2{Message: "oops", frame: xerrors.Caller(1)}
36 fmt.Printf("%v\n", err)
38 fmt.Printf("%+v\n", err)