You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

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