Merge pull request #419 from docker/errmeta-message

improve message for ErrMetaNotFound
This commit is contained in:
David Lawrence 2016-01-07 16:47:01 -08:00
commit cf57eaa511
4 changed files with 6 additions and 6 deletions

View File

@ -272,7 +272,7 @@ func (c *Client) downloadTimestamp() error {
if err == nil {
// couldn't retrieve data from server and don't have valid
// data in cache.
return store.ErrMetaNotFound{}
return store.ErrMetaNotFound{Resource: data.CanonicalTimestampRole}
}
return err
}

View File

@ -5,9 +5,9 @@ import "fmt"
// ErrMetaNotFound indicates we did not find a particular piece
// of metadata in the store
type ErrMetaNotFound struct {
Role string
Resource string
}
func (err ErrMetaNotFound) Error() string {
return fmt.Sprintf("%s trust data unavailable", err.Role)
return fmt.Sprintf("%s trust data unavailable. Has a notary repository been initialized?", err.Resource)
}

View File

@ -46,7 +46,7 @@ func (f *FilesystemStore) GetMeta(name string, size int64) ([]byte, error) {
meta, err := ioutil.ReadFile(path)
if err != nil {
if os.IsNotExist(err) {
err = ErrMetaNotFound{Role: name}
err = ErrMetaNotFound{Resource: name}
}
return nil, err
}

View File

@ -39,7 +39,7 @@ func (m *memoryStore) GetMeta(name string, size int64) ([]byte, error) {
}
return d[:size], nil
}
return nil, ErrMetaNotFound{}
return nil, ErrMetaNotFound{Resource: name}
}
func (m *memoryStore) SetMeta(name string, meta []byte) error {
@ -75,7 +75,7 @@ func (m *memoryStore) WalkStagedTargets(paths []string, targetsFn targetsWalkFun
for _, path := range paths {
dat, ok := m.files[path]
if !ok {
return ErrMetaNotFound{}
return ErrMetaNotFound{Resource: path}
}
meta, err := data.NewFileMeta(bytes.NewReader(dat), "sha256")
if err != nil {