Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(256)

Unified Diff: environs/configstore/disk.go

Issue 59930043: Add errgo as a dep, and start using it.
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: environs/configstore/disk.go
=== modified file 'environs/configstore/disk.go'
--- environs/configstore/disk.go 2014-01-28 04:58:43 +0000
+++ environs/configstore/disk.go 2014-02-03 14:31:54 +0000
@@ -9,6 +9,7 @@
"os"
"path/filepath"
+ "github.com/errgo/errgo"
"github.com/loggo/loggo"
"launchpad.net/goyaml"
@@ -162,14 +163,14 @@
func (info *environInfo) Write() error {
data, err := goyaml.Marshal(info)
if err != nil {
- return fmt.Errorf("cannot marshal environment info: %v", err)
+ return errgo.Annotate(err, "cannot marshal environment info")
}
// Create a temporary file and rename it, so that the data
// changes atomically.
parent, _ := filepath.Split(info.path)
tmpFile, err := ioutil.TempFile(parent, "")
if err != nil {
- return fmt.Errorf("cannot create temporary file: %v", err)
+ return errgo.Annotate(err, "cannot create temporary file")
}
_, err = tmpFile.Write(data)
// N.B. We need to close the file before renaming it
@@ -177,11 +178,11 @@
// error.
tmpFile.Close()
if err != nil {
- return fmt.Errorf("cannot write temporary file: %v", err)
+ return errgo.Annotate(err, "cannot write temporary file")
}
if err := utils.ReplaceFile(tmpFile.Name(), info.path); err != nil {
os.Remove(tmpFile.Name())
- return fmt.Errorf("cannot rename new environment info file: %v", err)
+ return errgo.Annotate(err, "cannot rename new environment info file")
}
info.initialized = true
return nil
« dependencies_test.go ('K') | « environs/config/config.go ('k') | environs/open.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b