~gophers/goose/unstable-001

« back to all changes in this revision

Viewing changes to errors/errors.go

MergeĀ ~wallyworld/goose/client-using-identity-cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
        "fmt"
8
8
)
9
9
 
10
 
// AddErrorContext prefixes any error stored in err with text formatted
 
10
// AddContext prefixes any error stored in err with text formatted
11
11
// according to the format specifier. If err does not contain an error,
12
 
// AddErrorContext does nothing.
13
 
func AddErrorContext(err *error, format string, args ...interface{}) {
14
 
        if *err != nil {
15
 
                *err = errors.New(fmt.Sprintf(format, args...) + ": " + (*err).Error())
 
12
// AddContext does nothing.
 
13
func AddContext(err error, format string, args ...interface{}) error {
 
14
        if err != nil {
 
15
                err = errors.New(fmt.Sprintf(format, args...) + ": " + err.Error())
16
16
        }
 
17
        return err
17
18
}