diff options
| author | Russ Cox <rsc@golang.org> | 2022-04-12 16:16:53 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2022-04-14 15:34:40 +0000 |
| commit | ae62a0b8f23348d14a0270fafc2ee02ef5149a2e (patch) | |
| tree | 79cd842d9abe2376488ae8fed72f764ab0872769 | |
| parent | f2105c4cf825fe09ece01c9d554f6c0a5bc06a03 (diff) | |
| download | go-x-review-ae62a0b8f23348d14a0270fafc2ee02ef5149a2e.tar.xz | |
git-codereview: print about all Gerrit API errors
Trying to chase down a problem with slow builders.
If this gets to be too chatty, we can limit it to builders.
For golang/go#50576.
Change-Id: I16c7818153d2444c897b4946ce7baebbd646ab23
Reviewed-on: https://go-review.googlesource.com/c/review/+/399116
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
| -rw-r--r-- | git-codereview/api.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/git-codereview/api.go b/git-codereview/api.go index 2adbcce..440489f 100644 --- a/git-codereview/api.go +++ b/git-codereview/api.go @@ -12,6 +12,7 @@ import ( "io/ioutil" "net/http" "net/url" + "os" "os/user" "path/filepath" "runtime" @@ -230,7 +231,15 @@ func (e *gerritError) Error() string { // gerritAPI expects to get a 200 response with a body consisting of an // anti-xss line (]})' or some such) followed by JSON. // If requestBody != nil, gerritAPI sets the Content-Type to application/json. -func gerritAPI(path string, requestBody []byte, target interface{}) error { +func gerritAPI(path string, requestBody []byte, target interface{}) (err error) { + defer func() { + if err != nil { + // os.Stderr, not stderr(), because the latter is not safe for + // use from multiple goroutines. + fmt.Fprintf(os.Stderr, "git-codereview: fetch %s: %v\n", path, err) + } + }() + // Strictly speaking, we might be able to use unauthenticated // access, by removing the /a/ from the URL, but that assumes // that all the information we care about is publicly visible. |
