Skip to content

Commit 806dea8

Browse files
fmt: document that if String or Error panics, that value is printed
Fixes #5350. R=r, minux.ma CC=golang-dev https://golang.org/cl/8950043
1 parent 13721cf commit 806dea8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/pkg/fmt/doc.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@
138138
by a single character (the verb) and end with a parenthesized
139139
description.
140140
141+
If an Error or String method triggers a panic when called by a
142+
print routine, the fmt package reformats the error message
143+
from the panic, decorating it with an indication that it came
144+
through the fmt package. For example, if a String method
145+
calls panic("bad"), the resulting formatted message will look
146+
like
147+
%s(PANIC=bad)
148+
149+
The %s just shows the print verb in use when the failure
150+
occurred.
141151
142152
Scanning
143153

0 commit comments

Comments
 (0)