From 29d0f02bd24541adbcee5c5b5583371c2b72d7d5 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Wed, 5 Jan 2011 11:39:57 -0800 Subject: [PATCH] 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 --- doc/effective_go.html | 13 ++++++++++++- doc/go_spec.html | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) 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: -- 2.50.0