2017-02-01 00:45:59 +00:00
|
|
|
package libcontainer
|
|
|
|
|
|
|
|
import "io"
|
|
|
|
|
2017-02-06 20:16:36 +00:00
|
|
|
// ErrorCode is the API error code type.
|
2017-02-01 00:45:59 +00:00
|
|
|
type ErrorCode int
|
|
|
|
|
|
|
|
// API error codes.
|
|
|
|
const (
|
|
|
|
// Factory errors
|
|
|
|
IdInUse ErrorCode = iota
|
|
|
|
InvalidIdFormat
|
|
|
|
|
|
|
|
// Container errors
|
|
|
|
ContainerNotExists
|
|
|
|
ContainerPaused
|
|
|
|
ContainerNotStopped
|
|
|
|
ContainerNotRunning
|
|
|
|
ContainerNotPaused
|
|
|
|
|
|
|
|
// Process errors
|
|
|
|
NoProcessOps
|
|
|
|
|
|
|
|
// Common errors
|
|
|
|
ConfigInvalid
|
|
|
|
ConsoleExists
|
|
|
|
SystemError
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c ErrorCode) String() string {
|
|
|
|
switch c {
|
|
|
|
case IdInUse:
|
|
|
|
return "Id already in use"
|
|
|
|
case InvalidIdFormat:
|
|
|
|
return "Invalid format"
|
|
|
|
case ContainerPaused:
|
|
|
|
return "Container paused"
|
|
|
|
case ConfigInvalid:
|
|
|
|
return "Invalid configuration"
|
|
|
|
case SystemError:
|
|
|
|
return "System error"
|
|
|
|
case ContainerNotExists:
|
|
|
|
return "Container does not exist"
|
|
|
|
case ContainerNotStopped:
|
|
|
|
return "Container is not stopped"
|
|
|
|
case ContainerNotRunning:
|
|
|
|
return "Container is not running"
|
|
|
|
case ConsoleExists:
|
|
|
|
return "Console exists for process"
|
|
|
|
case ContainerNotPaused:
|
|
|
|
return "Container is not paused"
|
|
|
|
case NoProcessOps:
|
|
|
|
return "No process operations"
|
|
|
|
default:
|
|
|
|
return "Unknown error"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-06 20:16:36 +00:00
|
|
|
// Error is the API error type.
|
2017-02-01 00:45:59 +00:00
|
|
|
type Error interface {
|
|
|
|
error
|
|
|
|
|
2017-02-06 20:16:36 +00:00
|
|
|
// Returns an error if it failed to write the detail of the Error to w.
|
|
|
|
// The detail of the Error may include the error message and a
|
|
|
|
// representation of the stack trace.
|
2017-02-01 00:45:59 +00:00
|
|
|
Detail(w io.Writer) error
|
|
|
|
|
|
|
|
// Returns the error code for this error.
|
|
|
|
Code() ErrorCode
|
|
|
|
}
|