]> Cypherpunks repositories - gostls13.git/commit
fmt: catch panics from calls to String etc.
authorRob Pike <r@golang.org>
Mon, 20 Jun 2011 22:31:02 +0000 (08:31 +1000)
committerRob Pike <r@golang.org>
Mon, 20 Jun 2011 22:31:02 +0000 (08:31 +1000)
commit97a929aac95301b850fb855e8e2fa8cfbe47ef59
tree2a345e02bcf0ae61ff71f48e73d568f62c02e179
parent4bbe9d87d77d871fa36095882117ff1316e12936
fmt: catch panics from calls to String etc.

This change causes Print et al. to catch panics generated by
calls to String, GoString, and Format.  The panic is formatted
into the output stream as an error, but the program continues.
As a special case, if the argument was a nil pointer, the
result is just "<nil>", because that's almost certainly enough
information and handles the very common case of String
methods that don't guard against nil.

Scan does not want this change. Input must work; output can
be for debugging and it's nice to get output even when you
make a mistake.

R=dsymonds, r, adg, gri, rsc, gri
CC=golang-dev
https://golang.org/cl/4640043
src/pkg/fmt/fmt_test.go
src/pkg/fmt/print.go