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

Commit

Permalink
do not pass nil to genericError
Browse files Browse the repository at this point in the history
currently genericError constructors require not-nil error to be able to read
its Error() message

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
  • Loading branch information
dqminh committed Mar 4, 2015
1 parent 025e6be commit 4ce8d97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (c *linuxContainer) Destroy() error {
return err
}
if status != Destroyed {
return newGenericError(nil, ContainerNotStopped)
return newGenericError(fmt.Errorf("container is not destroyed"), ContainerNotStopped)
}
if !c.config.Namespaces.Contains(configs.NEWPID) {
if err := killCgroupProcesses(c.cgroupManager); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions process.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package libcontainer

import (
"fmt"
"io"
"os"
)
Expand Down Expand Up @@ -46,23 +47,23 @@ type Process struct {
// Wait releases any resources associated with the Process
func (p Process) Wait() (*os.ProcessState, error) {
if p.ops == nil {
return nil, newGenericError(nil, ProcessNotExecuted)
return nil, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
}
return p.ops.wait()
}

// Pid returns the process ID
func (p Process) Pid() (int, error) {
if p.ops == nil {
return -1, newGenericError(nil, ProcessNotExecuted)
return -1, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
}
return p.ops.pid(), nil
}

// Signal sends a signal to the Process.
func (p Process) Signal(sig os.Signal) error {
if p.ops == nil {
return newGenericError(nil, ProcessNotExecuted)
return newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
}
return p.ops.signal(sig)
}
Expand Down

0 comments on commit 4ce8d97

Please sign in to comment.