mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1707 from AkihiroSuda/improve-error
improve error for getStore()
This commit is contained in:
commit
7ee02a3176
2 changed files with 10 additions and 2 deletions
|
@ -183,3 +183,11 @@ func (mr ManagerRedirectError) Error() string {
|
|||
|
||||
// Maskable denotes the type of this error
|
||||
func (mr ManagerRedirectError) Maskable() {}
|
||||
|
||||
// ErrDataStoreNotInitialized is returned if an invalid data scope is passed
|
||||
// for getting data store
|
||||
type ErrDataStoreNotInitialized string
|
||||
|
||||
func (dsni ErrDataStoreNotInitialized) Error() string {
|
||||
return fmt.Sprintf("datastore for scope %q is not initialized", string(dsni))
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
|
|||
func (c *controller) updateToStore(kvObject datastore.KVObject) error {
|
||||
cs := c.getStore(kvObject.DataScope())
|
||||
if cs == nil {
|
||||
return fmt.Errorf("datastore for scope %q is not initialized ", kvObject.DataScope())
|
||||
return ErrDataStoreNotInitialized(kvObject.DataScope())
|
||||
}
|
||||
|
||||
if err := cs.PutObjectAtomic(kvObject); err != nil {
|
||||
|
@ -241,7 +241,7 @@ func (c *controller) updateToStore(kvObject datastore.KVObject) error {
|
|||
func (c *controller) deleteFromStore(kvObject datastore.KVObject) error {
|
||||
cs := c.getStore(kvObject.DataScope())
|
||||
if cs == nil {
|
||||
return fmt.Errorf("datastore for scope %q is not initialized ", kvObject.DataScope())
|
||||
return ErrDataStoreNotInitialized(kvObject.DataScope())
|
||||
}
|
||||
|
||||
retry:
|
||||
|
|
Loading…
Add table
Reference in a new issue