Merge pull request #1003 from rajasec/container-error

Error handling when container not exists
This commit is contained in:
Qiang Huang 2016-08-27 11:18:55 +08:00 committed by GitHub
commit 189a2ab2f7
1 changed files with 3 additions and 3 deletions

View File

@ -188,7 +188,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
return nil, newGenericError(fmt.Errorf("invalid root"), ConfigInvalid)
}
containerRoot := filepath.Join(l.Root, id)
state, err := l.loadState(containerRoot)
state, err := l.loadState(containerRoot, id)
if err != nil {
return nil, err
}
@ -273,11 +273,11 @@ func (l *LinuxFactory) StartInitialization() (err error) {
return i.Init()
}
func (l *LinuxFactory) loadState(root string) (*State, error) {
func (l *LinuxFactory) loadState(root, id string) (*State, error) {
f, err := os.Open(filepath.Join(root, stateFilename))
if err != nil {
if os.IsNotExist(err) {
return nil, newGenericError(err, ContainerNotExists)
return nil, newGenericError(fmt.Errorf("container %q does not exists", id), ContainerNotExists)
}
return nil, newGenericError(err, SystemError)
}