2014-09-04 07:03:41 +08:00
|
|
|
package libcontainer
|
|
|
|
|
2014-10-23 07:27:06 +08:00
|
|
|
import "io"
|
|
|
|
|
2014-09-04 07:03:41 +08:00
|
|
|
// API error code type.
|
|
|
|
type ErrorCode int
|
|
|
|
|
|
|
|
// API error codes.
|
|
|
|
const (
|
|
|
|
// Factory errors
|
|
|
|
IdInUse ErrorCode = iota
|
|
|
|
InvalidIdFormat
|
|
|
|
|
|
|
|
// Container errors
|
2014-10-23 07:27:06 +08:00
|
|
|
ContainerNotExists
|
2014-09-04 07:03:41 +08:00
|
|
|
ContainerPaused
|
2014-12-15 23:00:04 +08:00
|
|
|
ContainerNotStopped
|
2015-02-12 09:42:58 +08:00
|
|
|
ContainerNotRunning
|
2016-01-22 08:43:33 +08:00
|
|
|
ContainerNotPaused
|
2014-09-04 07:03:41 +08:00
|
|
|
|
2015-02-23 17:26:43 +08:00
|
|
|
// Process errors
|
2016-01-21 01:16:12 +08:00
|
|
|
NoProcessOps
|
2015-02-23 17:26:43 +08:00
|
|
|
|
2014-09-04 07:03:41 +08:00
|
|
|
// Common errors
|
2014-09-06 01:08:11 +08:00
|
|
|
ConfigInvalid
|
2015-12-10 03:43:11 +08:00
|
|
|
ConsoleExists
|
2014-09-04 07:03:41 +08:00
|
|
|
SystemError
|
|
|
|
)
|
|
|
|
|
2014-10-23 04:45:23 +08:00
|
|
|
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:
|
2014-10-23 07:27:06 +08:00
|
|
|
return "System error"
|
|
|
|
case ContainerNotExists:
|
|
|
|
return "Container does not exist"
|
2014-12-15 23:00:04 +08:00
|
|
|
case ContainerNotStopped:
|
2015-02-12 09:42:58 +08:00
|
|
|
return "Container is not stopped"
|
|
|
|
case ContainerNotRunning:
|
|
|
|
return "Container is not running"
|
2015-12-10 03:43:11 +08:00
|
|
|
case ConsoleExists:
|
2015-12-11 21:37:32 +08:00
|
|
|
return "Console exists for process"
|
2016-01-22 08:43:33 +08:00
|
|
|
case ContainerNotPaused:
|
|
|
|
return "Container is not paused"
|
2016-01-21 01:16:12 +08:00
|
|
|
case NoProcessOps:
|
|
|
|
return "No process operations"
|
2014-10-23 04:45:23 +08:00
|
|
|
default:
|
|
|
|
return "Unknown error"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-04 07:03:41 +08:00
|
|
|
// API Error type.
|
|
|
|
type Error interface {
|
|
|
|
error
|
|
|
|
|
|
|
|
// Returns a verbose string including the error message
|
|
|
|
// and a representation of the stack trace suitable for
|
|
|
|
// printing.
|
2014-10-23 07:27:06 +08:00
|
|
|
Detail(w io.Writer) error
|
2014-09-04 07:03:41 +08:00
|
|
|
|
|
|
|
// Returns the error code for this error.
|
|
|
|
Code() ErrorCode
|
|
|
|
}
|