Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 4ce8d97

Browse files
committed
do not pass nil to genericError
currently genericError constructors require not-nil error to be able to read its Error() message Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
1 parent 025e6be commit 4ce8d97

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

container_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (c *linuxContainer) Destroy() error {
206206
return err
207207
}
208208
if status != Destroyed {
209-
return newGenericError(nil, ContainerNotStopped)
209+
return newGenericError(fmt.Errorf("container is not destroyed"), ContainerNotStopped)
210210
}
211211
if !c.config.Namespaces.Contains(configs.NEWPID) {
212212
if err := killCgroupProcesses(c.cgroupManager); err != nil {

process.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package libcontainer
22

33
import (
4+
"fmt"
45
"io"
56
"os"
67
)
@@ -46,23 +47,23 @@ type Process struct {
4647
// Wait releases any resources associated with the Process
4748
func (p Process) Wait() (*os.ProcessState, error) {
4849
if p.ops == nil {
49-
return nil, newGenericError(nil, ProcessNotExecuted)
50+
return nil, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
5051
}
5152
return p.ops.wait()
5253
}
5354

5455
// Pid returns the process ID
5556
func (p Process) Pid() (int, error) {
5657
if p.ops == nil {
57-
return -1, newGenericError(nil, ProcessNotExecuted)
58+
return -1, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
5859
}
5960
return p.ops.pid(), nil
6061
}
6162

6263
// Signal sends a signal to the Process.
6364
func (p Process) Signal(sig os.Signal) error {
6465
if p.ops == nil {
65-
return newGenericError(nil, ProcessNotExecuted)
66+
return newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
6667
}
6768
return p.ops.signal(sig)
6869
}

0 commit comments

Comments
 (0)