xerrors: change order of arguments of FormatError

To reflect the order of the FormatError method.

Change-Id: I29cc1495da42209934024e4baf1d0d466018a3f6
Reviewed-on: https://go-review.googlesource.com/c/159457
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/xerrors/adaptor.go b/xerrors/adaptor.go
index 5f0df17..038b10e 100644
--- a/xerrors/adaptor.go
+++ b/xerrors/adaptor.go
@@ -14,7 +14,7 @@
 
 // FormatError calls the FormatError method of err with a errors.Printer
 // configured according to s and verb and writes the result to s.
-func FormatError(s fmt.State, verb rune, f Formatter) {
+func FormatError(f Formatter, s fmt.State, verb rune) {
 	// Assuming this function is only called from the Format method, and given
 	// that FormatError takes precedence over Format, it cannot be called from
 	// any package that supports errors.Formatter. It is therefore safe to
diff --git a/xerrors/fmt.go b/xerrors/fmt.go
index 58dae3f..14aaea3 100644
--- a/xerrors/fmt.go
+++ b/xerrors/fmt.go
@@ -78,7 +78,7 @@
 	return fmt.Sprint(e)
 }
 
-func (e *noWrapError) Format(s fmt.State, v rune) { FormatError(s, v, e) }
+func (e *noWrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) }
 
 func (e *noWrapError) FormatError(p Printer) (next error) {
 	p.Print(e.msg)
@@ -96,7 +96,7 @@
 	return fmt.Sprint(e)
 }
 
-func (e *wrapError) Format(s fmt.State, v rune) { FormatError(s, v, e) }
+func (e *wrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) }
 
 func (e *wrapError) FormatError(p Printer) (next error) {
 	p.Print(e.msg)
diff --git a/xerrors/fmt_test.go b/xerrors/fmt_test.go
index 228f8e0..b38cfaf 100644
--- a/xerrors/fmt_test.go
+++ b/xerrors/fmt_test.go
@@ -355,7 +355,7 @@
 func (e wrapped) Error() string { return "should call Format" }
 
 func (e wrapped) Format(s fmt.State, verb rune) {
-	xerrors.FormatError(s, verb, &e)
+	xerrors.FormatError(&e, s, verb)
 }
 
 func (e wrapped) FormatError(p xerrors.Printer) (next error) {
@@ -386,7 +386,7 @@
 func (e *withFrameAndMore) Error() string { return fmt.Sprint(e) }
 
 func (e *withFrameAndMore) Format(s fmt.State, v rune) {
-	xerrors.FormatError(s, v, e)
+	xerrors.FormatError(e, s, v)
 }
 
 func (e *withFrameAndMore) FormatError(p xerrors.Printer) (next error) {
@@ -404,7 +404,7 @@
 
 // move to 1_12 test file
 func (e spurious) Format(s fmt.State, verb rune) {
-	xerrors.FormatError(s, verb, e)
+	xerrors.FormatError(e, s, verb)
 }
 
 func (e spurious) FormatError(p xerrors.Printer) (next error) {
@@ -426,7 +426,7 @@
 func (e adapted) Error() string { return string(e.msg) }
 
 func (e adapted) Format(s fmt.State, verb rune) {
-	xerrors.FormatError(s, verb, e)
+	xerrors.FormatError(e, s, verb)
 }
 
 func (e adapted) FormatError(p xerrors.Printer) error {
@@ -475,7 +475,7 @@
 func (e fmtTwiceErr) Error() string { return fmt.Sprint(e) }
 
 func (e fmtTwiceErr) Format(s fmt.State, verb rune) {
-	xerrors.FormatError(s, verb, e)
+	xerrors.FormatError(e, s, verb)
 }
 
 func (e fmtTwiceErr) FormatError(p xerrors.Printer) (next error) {