Skip to content

Commit 189a2ab

Browse files
authored
Merge pull request #1003 from rajasec/container-error
Error handling when container not exists
2 parents face64a + 714550f commit 189a2ab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libcontainer/factory_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
188188
return nil, newGenericError(fmt.Errorf("invalid root"), ConfigInvalid)
189189
}
190190
containerRoot := filepath.Join(l.Root, id)
191-
state, err := l.loadState(containerRoot)
191+
state, err := l.loadState(containerRoot, id)
192192
if err != nil {
193193
return nil, err
194194
}
@@ -273,11 +273,11 @@ func (l *LinuxFactory) StartInitialization() (err error) {
273273
return i.Init()
274274
}
275275

276-
func (l *LinuxFactory) loadState(root string) (*State, error) {
276+
func (l *LinuxFactory) loadState(root, id string) (*State, error) {
277277
f, err := os.Open(filepath.Join(root, stateFilename))
278278
if err != nil {
279279
if os.IsNotExist(err) {
280-
return nil, newGenericError(err, ContainerNotExists)
280+
return nil, newGenericError(fmt.Errorf("container %q does not exists", id), ContainerNotExists)
281281
}
282282
return nil, newGenericError(err, SystemError)
283283
}

0 commit comments

Comments
 (0)