From: Rob Pike Date: Wed, 5 Jan 2011 19:39:57 +0000 (-0800) Subject: effective go: explain the effect of repanicking better. X-Git-Tag: weekly.2011-01-06~9 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=29d0f02bd24541adbcee5c5b5583371c2b72d7d5;p=gostls13.git effective go: explain the effect of repanicking better. Also fix a

error in go_spec.html. Fixes #1370. R=rsc, gri CC=golang-dev https://golang.org/cl/3835043 --- diff --git a/doc/effective_go.html b/doc/effective_go.html index b70d60a925..26e317b5d2 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -2792,7 +2792,7 @@ user-triggered errors.

-With this error handling in place, the error method +With error handling in place, the error method makes it easy to report parse errors without worrying about unwinding the parse stack by hand.

@@ -2804,6 +2804,17 @@ Useful though this pattern is, it should be used only within a package. to its client. That is a good rule to follow.

+

+By the way, this re-panic idiom changes the panic value if an actual +error occurs. However, both the original and new failures will be +presented in the crash report, so the root cause of the problem will +still be visible. Thus this simple re-panic approach is usually +sufficient—it's a crash after all—but if you want to +display only the original value, you can write a little more code to +filter unexpected problems and re-panic with the original error. +That's left as an exercise for the reader. +

+

A web server

diff --git a/doc/go_spec.html b/doc/go_spec.html index 1b1deaba2c..d12d51344d 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3973,9 +3973,9 @@ As with an assignment, the operands on the left must be addressable or map index expressions; they denote the iteration variables. If the range expression is a channel, only one iteration variable is permitted, otherwise there may be one or two. -

-

+ +

The range expression is evaluated once before beginning the loop. Function calls on the left are evaluated once per iteration. For each iteration, iteration values are produced as follows: