1/* 2Copyright 2014 The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17package exec 18 19// ExitError is an interface that presents an API similar to os.ProcessState, which is 20// what ExitError from os/exec is. This is designed to make testing a bit easier and 21// probably loses some of the cross-platform properties of the underlying library. 22type ExitError interface { 23 String() string 24 Error() string 25 Exited() bool 26 ExitStatus() int 27} 28 29// CodeExitError is an implementation of ExitError consisting of an error object 30// and an exit code (the upper bits of os.exec.ExitStatus). 31type CodeExitError struct { 32 Err error 33 Code int 34} 35 36var _ ExitError = CodeExitError{} 37 38func (e CodeExitError) Error() string { 39 return e.Err.Error() 40} 41 42func (e CodeExitError) String() string { 43 return e.Err.Error() 44} 45 46func (e CodeExitError) Exited() bool { 47 return true 48} 49 50func (e CodeExitError) ExitStatus() int { 51 return e.Code 52} 53