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

Side by Side Diff: tokenserver/appengine/impl/certconfig/rpc_fetch_crl.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
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 certconfig 5 package certconfig
6 6
7 import ( 7 import (
8 "crypto/x509" 8 "crypto/x509"
9 "fmt" 9 "fmt"
10 "io/ioutil" 10 "io/ioutil"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 // Read the body in its entirety. 136 // Read the body in its entirety.
137 blob, err = ioutil.ReadAll(resp.Body) 137 blob, err = ioutil.ReadAll(resp.Body)
138 if err != nil { 138 if err != nil {
139 return nil, "", transient.Tag.Apply(err) 139 return nil, "", transient.Tag.Apply(err)
140 } 140 }
141 141
142 // Transient error? 142 // Transient error?
143 if resp.StatusCode >= http.StatusInternalServerError { 143 if resp.StatusCode >= http.StatusInternalServerError {
144 logging.Warningf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Sta tusCode, string(blob)) 144 logging.Warningf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Sta tusCode, string(blob))
145 » » return nil, "", errors.Reason("server replied with HTTP %(code)d "). 145 » » return nil, "", errors.Reason("server replied with HTTP %d", res p.StatusCode).
146 » » » D("code", resp.StatusCode).Tag(transient.Tag).Err() 146 » » » Tag(transient.Tag).Err()
147 } 147 }
148 148
149 // Something we don't support or expect? 149 // Something we don't support or expect?
150 if resp.StatusCode != http.StatusOK { 150 if resp.StatusCode != http.StatusOK {
151 logging.Errorf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Statu sCode, string(blob)) 151 logging.Errorf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Statu sCode, string(blob))
152 return nil, "", fmt.Errorf("unexpected status HTTP %d", resp.Sta tusCode) 152 return nil, "", fmt.Errorf("unexpected status HTTP %d", resp.Sta tusCode)
153 } 153 }
154 154
155 // Good enough. 155 // Good enough.
156 return blob, resp.Header.Get("ETag"), nil 156 return blob, resp.Header.Get("ETag"), nil
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 return ds.Put(c, toPut) 215 return ds.Put(c, toPut)
216 }, nil) 216 }, nil)
217 if err != nil { 217 if err != nil {
218 return nil, transient.Tag.Apply(err) 218 return nil, transient.Tag.Apply(err)
219 } 219 }
220 220
221 logging.Infof(c, "CRL for %q is updated, entity version is %d", ca.CN, u pdated.EntityVersion) 221 logging.Infof(c, "CRL for %q is updated, entity version is %d", ca.CN, u pdated.EntityVersion)
222 return updated, nil 222 return updated, nil
223 } 223 }
OLDNEW
« no previous file with comments | « milo/build_source/swarming/buildinfo.go ('k') | tokenserver/appengine/impl/utils/policy/policy.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698