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

Side by Side Diff: common/tsmon/config.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 | « common/system/prober/probe.go ('k') | common/tsmon/iface.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 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 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 tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "os" 9 "os"
10 "runtime" 10 "runtime"
(...skipping 19 matching lines...) Expand all
30 return ret, nil 30 return ret, nil
31 } 31 }
32 32
33 file, err := os.Open(path) 33 file, err := os.Open(path)
34 switch { 34 switch {
35 case err == nil: 35 case err == nil:
36 defer file.Close() 36 defer file.Close()
37 37
38 decoder := json.NewDecoder(file) 38 decoder := json.NewDecoder(file)
39 if err = decoder.Decode(&ret); err != nil { 39 if err = decoder.Decode(&ret); err != nil {
40 » » » return ret, errors.Annotate(err).Reason("failed to decod e file").Err() 40 » » » return ret, errors.Annotate(err, "failed to decode file" ).Err()
41 } 41 }
42 return ret, nil 42 return ret, nil
43 43
44 case os.IsNotExist(err): 44 case os.IsNotExist(err):
45 // The file does not exist. We don't consider this an error, sin ce the file 45 // The file does not exist. We don't consider this an error, sin ce the file
46 // is optional. 46 // is optional.
47 return ret, nil 47 return ret, nil
48 48
49 default: 49 default:
50 // An unexpected failure occurred. 50 // An unexpected failure occurred.
51 » » return ret, errors.Annotate(err).Reason("failed to open file").E rr() 51 » » return ret, errors.Annotate(err, "failed to open file").Err()
52 } 52 }
53 } 53 }
54 54
55 func defaultConfigFilePath() string { 55 func defaultConfigFilePath() string {
56 // TODO(vadimsh): Move this to "hardcoded/chromeinfra" package. 56 // TODO(vadimsh): Move this to "hardcoded/chromeinfra" package.
57 if runtime.GOOS == "windows" { 57 if runtime.GOOS == "windows" {
58 return "C:\\chrome-infra\\ts-mon.json" 58 return "C:\\chrome-infra\\ts-mon.json"
59 } 59 }
60 return "/etc/chrome-infra/ts-mon.json" 60 return "/etc/chrome-infra/ts-mon.json"
61 } 61 }
OLDNEW
« no previous file with comments | « common/system/prober/probe.go ('k') | common/tsmon/iface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698