error-values: clarify how to use the adapter
Make it clear that one's error type must provide Error and FormatError
methods in addition to Format.
Change-Id: Ic21c3a212b9fa4eb8efddac49bff10d0515fa641
Reviewed-on: https://go-review.googlesource.com/c/159499
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/design/29934-error-values.md b/design/29934-error-values.md
index b138f71..f8d49d8 100644
--- a/design/29934-error-values.md
+++ b/design/29934-error-values.md
@@ -5,7 +5,7 @@
Marcel van Lohuizen\
Damien Neil
-Last updated: January 24, 2019
+Last updated: January 25, 2019
Discussion at: https://golang.org/issue/29934
@@ -244,10 +244,14 @@
formatting implementation. An error implementation can make sure earlier Go
versions call its `FormatError` method by adding this `Format` method:
```
- type MyError …
+ type MyError ...
+
func (m *MyError) Format(f fmt.State, c rune) { // implements fmt.Formatter
- xerrors.FormatError(m, f, c)
+ xerrors.FormatError(m, f, c) // will call m.FormatError
}
+
+ func (m *MyError) Error() string { ... }
+ func (m *MyError) FormatError(p xerrors.Printer) error { ... }
```
## Rationale