~cmars/juju-core/1.14-azure-compile-error

« back to all changes in this revision

Viewing changes to environs/maas/storage.go

Move common errors to erros package and remove dupe NotFoundError struct

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
        "io/ioutil"
12
12
        "launchpad.net/gomaasapi"
13
13
        "launchpad.net/juju-core/environs"
 
14
        "launchpad.net/juju-core/errors"
14
15
        "net/url"
15
16
        "sort"
16
17
        "sync"
67
68
// its download URL and its contents, as a MAASObject.
68
69
//
69
70
// This may return many different errors, but specifically, it returns
70
 
// (a pointer to) environs.NotFoundError if the file did not exist.
 
71
// (a pointer to) errors.NotFoundError if the file did not exist.
71
72
//
72
73
// The function takes out a lock on the storage object.
73
74
func (stor *maasStorage) retrieveFileObject(name string) (gomaasapi.MAASObject, error) {
76
77
                noObj := gomaasapi.MAASObject{}
77
78
                serverErr, ok := err.(gomaasapi.ServerError)
78
79
                if ok && serverErr.StatusCode == 404 {
79
 
                        msg := fmt.Errorf("file '%s' not found", name)
80
 
                        return noObj, &environs.NotFoundError{msg}
 
80
                        return noObj, errors.NotFoundf("file '%s' not found", name)
81
81
                }
82
82
                msg := fmt.Errorf("could not access file '%s': %v", name, err)
83
83
                return noObj, msg