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

Unified Diff: provider/azure/environ.go

Issue 70770043: all: use errgo instead of fmt.Errorf
Patch Set: all: use errgo instead of fmt.Errorf Created 11 years, 1 month 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
« no previous file with comments | « provider/azure/customdata.go ('k') | provider/azure/instance.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: provider/azure/environ.go
=== modified file 'provider/azure/environ.go'
--- provider/azure/environ.go 2014-02-18 03:18:16 +0000
+++ provider/azure/environ.go 2014-03-03 12:02:05 +0000
@@ -9,6 +9,7 @@
"sync"
"time"
+ "github.com/juju/errgo/errors"
"launchpad.net/gwacl"
"launchpad.net/juju-core/constraints"
@@ -112,12 +113,12 @@
accountName := env.getSnapshot().ecfg.storageAccountName()
keys, err := azure.GetStorageAccountKeys(accountName)
if err != nil {
- return "", fmt.Errorf("cannot obtain storage account keys: %v", err)
+ return "", errors.Notef(err, "cannot obtain storage account keys")
}
key := extractStorageKey(keys)
if key == "" {
- return "", fmt.Errorf("no keys available for storage account")
+ return "", errors.Newf("no keys available for storage account")
}
return key, nil
@@ -315,10 +316,10 @@
svc, err = attemptCreateService(azure, prefix, affinityGroupName, location)
}
if err != nil {
- return nil, fmt.Errorf("could not create hosted service: %v", err)
+ return nil, errors.Notef(err, "could not create hosted service")
}
if svc == nil {
- return nil, fmt.Errorf("could not come up with a unique hosted service name - is your randomizer initialized?")
+ return nil, errors.Newf("could not come up with a unique hosted service name - is your randomizer initialized?")
}
return svc, nil
}
@@ -382,7 +383,7 @@
// Compose userdata.
userData, err := makeCustomData(machineConfig)
if err != nil {
- return nil, nil, fmt.Errorf("custom data: %v", err)
+ return nil, nil, errors.Notef(err, "custom data")
}
azure, err := env.getManagementAPI()
@@ -468,7 +469,7 @@
defer env.releaseManagementAPI(context)
service, err := context.GetHostedServiceProperties(instanceName, false)
if err != nil {
- return nil, fmt.Errorf("could not get instance %q: %v", instanceName, err)
+ return nil, errors.Notef(err, "could not get instance %q", instanceName)
}
instance := &azureInstance{service.HostedServiceDescriptor, env}
return instance, nil
@@ -664,21 +665,21 @@
// Stop all instances.
insts, err := env.AllInstances()
if err != nil {
- return fmt.Errorf("cannot get instances: %v", err)
+ return errors.Notef(err, "cannot get instances")
}
err = env.StopInstances(insts)
if err != nil {
- return fmt.Errorf("cannot stop instances: %v", err)
+ return errors.Notef(err, "cannot stop instances")
}
// Delete vnet and affinity group.
err = env.deleteVirtualNetwork()
if err != nil {
- return fmt.Errorf("cannot delete the environment's virtual network: %v", err)
+ return errors.Notef(err, "cannot delete the environment's virtual network")
}
err = env.deleteAffinityGroup()
if err != nil {
- return fmt.Errorf("cannot delete the environment's affinity group: %v", err)
+ return errors.Notef(err, "cannot delete the environment's affinity group")
}
// Delete storage.
@@ -688,7 +689,7 @@
// a "error: environment is already bootstrapped" error.
err = env.Storage().RemoveAll()
if err != nil {
- return fmt.Errorf("cannot clean up storage: %v", err)
+ return errors.Notef(err, "cannot clean up storage")
}
return nil
}
@@ -818,7 +819,7 @@
// anyway. Otherwise, it might be worth returning the key
// just in case it still works, and proceed without updating
// env.storageAccountKey.
- return "", fmt.Errorf("environment was reconfigured")
+ return "", errors.Newf("environment was reconfigured")
}
// Write back changes.
« no previous file with comments | « provider/azure/customdata.go ('k') | provider/azure/instance.go » ('j') | no next file with comments »

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