1// Copyright 2018 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.
4
5package xerrors
6
7// A Formatter formats error messages.
8type Formatter interface {
9	error
10
11	// FormatError prints the receiver's first error and returns the next error in
12	// the error chain, if any.
13	FormatError(p Printer) (next error)
14}
15
16// A Printer formats error messages.
17//
18// The most common implementation of Printer is the one provided by package fmt
19// during Printf (as of Go 1.13). Localization packages such as golang.org/x/text/message
20// typically provide their own implementations.
21type Printer interface {
22	// Print appends args to the message output.
23	Print(args ...interface{})
24
25	// Printf writes a formatted string.
26	Printf(format string, args ...interface{})
27
28	// Detail reports whether error detail is requested.
29	// After the first call to Detail, all text written to the Printer
30	// is formatted as additional detail, or ignored when
31	// detail has not been requested.
32	// If Detail returns false, the caller can avoid printing the detail at all.
33	Detail() bool
34}
35