mirror of
				https://github.com/opencontainers/runc.git
				synced 2025-10-31 11:06:21 +08:00 
			
		
		
		
	 e918d02139
			
		
	
	e918d02139
	
	
	
		
			
			This removes libcontainer's own error wrapping system, consisting of a few types and functions, aimed at typization, wrapping and unwrapping of errors, as well as saving error stack traces. Since Go 1.13 now provides its own error wrapping mechanism and a few related functions, it makes sense to switch to it. While doing that, improve some error messages so that they start with "error", "unable to", or "can't". A few things that are worth mentioning: 1. We lose stack traces (which were never shown anyway). 2. Users of libcontainer that relied on particular errors (like ContainerNotExists) need to switch to using errors.Is with the new errors defined in error.go. 3. encoding/json is unable to unmarshal the built-in error type, so we have to introduce initError and wrap the errors into it (basically passing the error as a string). This is the same as it was before, just a tad simpler (actually the initError is a type that got removed in commit afa844311; also suddenly ierr variable name makes sense now). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
		
			
				
	
	
		
			22 lines
		
	
	
		
			573 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			573 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package libcontainer
 | |
| 
 | |
| import "errors"
 | |
| 
 | |
| var (
 | |
| 	ErrExist      = errors.New("container with given ID already exists")
 | |
| 	ErrInvalidID  = errors.New("invalid container ID format")
 | |
| 	ErrNotExist   = errors.New("container does not exist")
 | |
| 	ErrPaused     = errors.New("container paused")
 | |
| 	ErrRunning    = errors.New("container still running")
 | |
| 	ErrNotRunning = errors.New("container not running")
 | |
| 	ErrNotPaused  = errors.New("container not paused")
 | |
| )
 | |
| 
 | |
| type ConfigError struct {
 | |
| 	details string
 | |
| }
 | |
| 
 | |
| func (e *ConfigError) Error() string {
 | |
| 	return "invalid configuration: " + e.details
 | |
| }
 |