mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
only os.Exits on error
This commit is contained in:
parent
9b088ada7e
commit
46a1cd69a9
3 changed files with 15 additions and 1 deletions
|
@ -1479,7 +1479,9 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
os.Exit(status)
|
||||
if status != 0 {
|
||||
return &utils.StatusError{status}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -75,6 +75,9 @@ func main() {
|
|||
}
|
||||
protoAddrParts := strings.SplitN(flHosts[0], "://", 2)
|
||||
if err := docker.ParseCommands(protoAddrParts[0], protoAddrParts[1], flag.Args()...); err != nil {
|
||||
if sterr, ok := err.(*utils.StatusError); ok {
|
||||
os.Exit(sterr.Status)
|
||||
}
|
||||
log.Fatal(err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
|
|
@ -1012,3 +1012,12 @@ func (graph *DependencyGraph) GenerateTraversalMap() ([][]string, error) {
|
|||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// An StatusError reports an unsuccessful exit by a command.
|
||||
type StatusError struct {
|
||||
Status int
|
||||
}
|
||||
|
||||
func (e *StatusError) Error() string {
|
||||
return fmt.Sprintf("Status: %d", e.Status)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue