errors: Create a new standard error for invalid config

Refactor a common error into a new standard error object.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2019-04-15 09:28:35 +01:00
parent e803a7f870
commit 97beb2b2d4
2 changed files with 9 additions and 8 deletions

View File

@ -189,7 +189,7 @@ func (k *kataAgent) init(ctx context.Context, sandbox *Sandbox, config interface
}
k.keepConn = c.LongLiveConn
default:
return fmt.Errorf("Invalid config type")
return vcTypes.ErrInvalidConfigType
}
k.proxy, err = newProxy(sandbox.config.ProxyType)
@ -241,7 +241,7 @@ func (k *kataAgent) internalConfigure(h hypervisor, id, sharePath string, builti
}
k.keepConn = c.LongLiveConn
default:
return fmt.Errorf("Invalid config type")
return vcTypes.ErrInvalidConfigType
}
}
@ -275,7 +275,7 @@ func (k *kataAgent) configure(h hypervisor, id, sharePath string, builtin bool,
}
k.vmSocket = s
default:
return fmt.Errorf("Invalid config type")
return vcTypes.ErrInvalidConfigType
}
// Neither create shared directory nor add 9p device if hypervisor

View File

@ -11,9 +11,10 @@ import (
// common error objects used for argument checking
var (
ErrNeedSandbox = errors.New("Sandbox must be specified")
ErrNeedSandboxID = errors.New("Sandbox ID cannot be empty")
ErrNeedContainerID = errors.New("Container ID cannot be empty")
ErrNeedState = errors.New("State cannot be empty")
ErrNoSuchContainer = errors.New("Container does not exist")
ErrNeedSandbox = errors.New("Sandbox must be specified")
ErrNeedSandboxID = errors.New("Sandbox ID cannot be empty")
ErrNeedContainerID = errors.New("Container ID cannot be empty")
ErrNeedState = errors.New("State cannot be empty")
ErrNoSuchContainer = errors.New("Container does not exist")
ErrInvalidConfigType = errors.New("Invalid config type")
)