Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: grpc/prpc/client.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « grpc/grpcutil/errors.go ('k') | logdog/appengine/coordinator/endpoints/logs/get.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package prpc 5 package prpc
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "io" 10 "io"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 req.Body = ioutil.NopCloser(bytes.NewReader(in)) 197 req.Body = ioutil.NopCloser(bytes.NewReader(in))
198 res, err := ctxhttp.Do(ctx, c.getHTTPClient(), req) 198 res, err := ctxhttp.Do(ctx, c.getHTTPClient(), req)
199 if res != nil && res.Body != nil { 199 if res != nil && res.Body != nil {
200 defer res.Body.Close() 200 defer res.Body.Close()
201 } 201 }
202 if c.testPostHTTP != nil { 202 if c.testPostHTTP != nil {
203 err = c.testPostHTTP(ctx, err) 203 err = c.testPostHTTP(ctx, err)
204 } 204 }
205 if err != nil { 205 if err != nil {
206 // Treat all errors here as transient. 206 // Treat all errors here as transient.
207 » » » » return errors.Annotate(err).Reason("failed to se nd request"). 207 » » » » return errors.Annotate(err, "failed to send requ est").Tag(transient.Tag).Err()
208 » » » » » Tag(transient.Tag).Err()
209 } 208 }
210 209
211 if options.resHeaderMetadata != nil { 210 if options.resHeaderMetadata != nil {
212 *options.resHeaderMetadata = metadataFromHeaders (res.Header) 211 *options.resHeaderMetadata = metadataFromHeaders (res.Header)
213 } 212 }
214 contentType = res.Header.Get("Content-Type") 213 contentType = res.Header.Get("Content-Type")
215 214
216 // Read the response body. 215 // Read the response body.
217 buf.Reset() 216 buf.Reset()
218 var body io.Reader = res.Body 217 var body io.Reader = res.Body
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if len(h) == 0 { 363 if len(h) == 0 {
365 return nil 364 return nil
366 } 365 }
367 366
368 md := make(metadata.MD, len(h)) 367 md := make(metadata.MD, len(h))
369 for k, v := range h { 368 for k, v := range h {
370 md[strings.ToLower(k)] = v 369 md[strings.ToLower(k)] = v
371 } 370 }
372 return md 371 return md
373 } 372 }
OLDNEW
« no previous file with comments | « grpc/grpcutil/errors.go ('k') | logdog/appengine/coordinator/endpoints/logs/get.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698