Merge pull request #515 from fate-grand-order/branch

Use errors.New() directly to output the error message
This commit is contained in:
Michael Crosby 2017-02-10 13:55:10 -08:00 committed by GitHub
commit 89f62d4fae
8 changed files with 13 additions and 12 deletions

View file

@ -123,7 +123,7 @@ func main() {
debugPath := context.GlobalString("debug-socket")
if debugPath == "" {
return fmt.Errorf("--debug-socket path cannot be empty")
return errors.New("--debug-socket path cannot be empty")
}
d, err := utils.CreateUnixSocket(debugPath)
if err != nil {
@ -138,7 +138,7 @@ func main() {
path := context.GlobalString("socket")
if path == "" {
return fmt.Errorf("--socket path cannot be empty")
return errors.New("--socket path cannot be empty")
}
l, err := utils.CreateUnixSocket(path)
if err != nil {

View file

@ -2,7 +2,7 @@ package main
import (
gocontext "context"
"fmt"
"errors"
"github.com/docker/containerd/api/execution"
"github.com/urfave/cli"
@ -26,7 +26,7 @@ var deleteCommand = cli.Command{
id := context.Args().First()
if id == "" {
return fmt.Errorf("container id must be provided")
return errors.New("container id must be provided")
}
pid := uint32(context.Int64("pid"))

View file

@ -2,7 +2,7 @@ package main
import (
gocontext "context"
"fmt"
"errors"
"github.com/davecgh/go-spew/spew"
"github.com/docker/containerd/api/execution"
@ -20,7 +20,7 @@ var inspectCommand = cli.Command{
}
id := context.Args().First()
if id == "" {
return fmt.Errorf("container id must be provided")
return errors.New("container id must be provided")
}
getResponse, err := executionService.GetContainer(gocontext.Background(),
&execution.GetContainerRequest{ID: id})

View file

@ -22,7 +22,7 @@ var listCommand = cli.Command{
if err != nil {
return err
}
fmt.Printf("ID\tSTATUS\tPROCS\tBUNDLE\n")
fmt.Println("ID\tSTATUS\tPROCS\tBUNDLE")
for _, c := range listResponse.Containers {
listProcResponse, err := executionService.ListProcesses(gocontext.Background(),
&execution.ListProcessesRequest{ContainerID: c.ID})

View file

@ -20,6 +20,7 @@ import (
"github.com/crosbymichael/console"
"github.com/docker/containerd/api/shim"
"github.com/urfave/cli"
"github.com/pkg/errors"
)
var fifoFlags = []cli.Flag{
@ -75,7 +76,7 @@ var shimCreateCommand = cli.Command{
Action: func(context *cli.Context) error {
id := context.Args().First()
if id == "" {
return fmt.Errorf("container id must be provided")
return errors.New("container id must be provided")
}
service, err := getShimService()
if err != nil {

2
cmd/dist/active.go vendored
View file

@ -54,7 +54,7 @@ var activeCommand = cli.Command{
}
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0)
fmt.Fprintf(tw, "REF\tSIZE\tAGE\n")
fmt.Fprintln(tw, "REF\tSIZE\tAGE")
for _, active := range active {
fmt.Fprintf(tw, "%s\t%s\t%s\n",
active.Ref,

4
cmd/dist/fetch.go vendored
View file

@ -52,11 +52,11 @@ var fetchCommand = cli.Command{
}
if locator == "" {
return fmt.Errorf("containerd: remote required")
return errors.New("containerd: remote required")
}
if len(args) < 1 {
return fmt.Errorf("containerd: object required")
return errors.New("containerd: object required")
}
object := args[0]

View file

@ -60,7 +60,7 @@ func DumpDir(t *testing.T, root string) {
} else if fi.Mode().IsRegular() {
p, err := ioutil.ReadFile(path)
if err != nil {
t.Log("error reading file: %v", err)
t.Logf("error reading file: %v", err)
return nil
}