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

Unified Diff: agent/agent.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 | « [revision details] ('k') | agent/bootstrap.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: agent/agent.go
=== modified file 'agent/agent.go'
--- agent/agent.go 2014-02-27 04:43:37 +0000
+++ agent/agent.go 2014-03-03 12:12:14 +0000
@@ -4,12 +4,11 @@
package agent
import (
- "fmt"
"path"
"regexp"
"sync"
- "github.com/errgo/errgo"
+ errgo "github.com/juju/errgo/errors"
"github.com/loggo/loggo"
"launchpad.net/juju-core/errors"
@@ -160,19 +159,19 @@
// machine or unit agent.
func NewAgentConfig(configParams AgentConfigParams) (Config, error) {
if configParams.DataDir == "" {
- return nil, errgo.Trace(requiredError("data directory"))
+ return nil, requiredError("data directory")
}
if configParams.Tag == "" {
- return nil, errgo.Trace(requiredError("entity tag"))
+ return nil, requiredError("entity tag")
}
if configParams.UpgradedToVersion == version.Zero {
- return nil, errgo.Trace(requiredError("upgradedToVersion"))
+ return nil, requiredError("upgradedToVersion")
}
if configParams.Password == "" {
- return nil, errgo.Trace(requiredError("password"))
+ return nil, requiredError("password")
}
if configParams.CACert == nil {
- return nil, errgo.Trace(requiredError("CA certificate"))
+ return nil, requiredError("CA certificate")
}
// Note that the password parts of the state and api information are
// blank. This is by design.
@@ -216,10 +215,10 @@
// a machine running the state server.
func NewStateMachineConfig(configParams StateMachineConfigParams) (Config, error) {
if configParams.StateServerCert == nil {
- return nil, errgo.Trace(requiredError("state server cert"))
+ return nil, requiredError("state server cert")
}
if configParams.StateServerKey == nil {
- return nil, errgo.Trace(requiredError("state server key"))
+ return nil, requiredError("state server key")
}
config0, err := NewAgentConfig(configParams.AgentConfigParams)
if err != nil {
@@ -278,7 +277,7 @@
}
func requiredError(what string) error {
- return fmt.Errorf("%s not found in configuration", what)
+ return errgo.Newf("%s not found in configuration", what)
}
func (c *configInternal) File(name string) string {
@@ -326,7 +325,7 @@
func (c *configInternal) APIAddresses() ([]string, error) {
if c.apiDetails == nil {
- return []string{}, errgo.New("No apidetails in config")
+ return []string{}, errgo.Newf("No apidetails in config")
}
return append([]string{}, c.apiDetails.addresses...), nil
}
@@ -341,7 +340,7 @@
func (c *configInternal) check() error {
if c.stateDetails == nil && c.apiDetails == nil {
- return errgo.Trace(requiredError("state or API addresses"))
+ return requiredError("state or API addresses")
}
if c.stateDetails != nil {
if err := checkAddrs(c.stateDetails.addresses, "state server address"); err != nil {
@@ -360,11 +359,11 @@
func checkAddrs(addrs []string, what string) error {
if len(addrs) == 0 {
- return errgo.Trace(requiredError(what))
+ return requiredError(what)
}
for _, a := range addrs {
if !validAddr.MatchString(a) {
- return errgo.New("invalid %s %q", what, a)
+ return errgo.Newf("invalid %s %q", what, a)
}
}
return nil
« no previous file with comments | « [revision details] ('k') | agent/bootstrap.go » ('j') | no next file with comments »

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