Use error.New () directly to output the error message

Signed-off-by: fate-grand-order <chenjg@harmonycloud.cn>
This commit is contained in:
fate-grand-order 2017-02-10 12:32:11 +08:00
parent 696e88c813
commit af86cd4d2f
8 changed files with 13 additions and 12 deletions

View file

@ -110,7 +110,7 @@ func main() {
debugPath := context.GlobalString("debug-socket") debugPath := context.GlobalString("debug-socket")
if debugPath == "" { 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) d, err := utils.CreateUnixSocket(debugPath)
if err != nil { if err != nil {
@ -125,7 +125,7 @@ func main() {
path := context.GlobalString("socket") path := context.GlobalString("socket")
if path == "" { if path == "" {
return fmt.Errorf("--socket path cannot be empty") return errors.New("--socket path cannot be empty")
} }
l, err := utils.CreateUnixSocket(path) l, err := utils.CreateUnixSocket(path)
if err != nil { if err != nil {

View file

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

View file

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

View file

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

View file

@ -20,6 +20,7 @@ import (
"github.com/crosbymichael/console" "github.com/crosbymichael/console"
"github.com/docker/containerd/api/shim" "github.com/docker/containerd/api/shim"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/pkg/errors"
) )
var fifoFlags = []cli.Flag{ var fifoFlags = []cli.Flag{
@ -75,7 +76,7 @@ var shimCreateCommand = cli.Command{
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
id := context.Args().First() id := context.Args().First()
if id == "" { if id == "" {
return fmt.Errorf("container id must be provided") return errors.New("container id must be provided")
} }
service, err := getShimService() service, err := getShimService()
if err != nil { 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) 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 { for _, active := range active {
fmt.Fprintf(tw, "%s\t%s\t%s\n", fmt.Fprintf(tw, "%s\t%s\t%s\n",
active.Ref, active.Ref,

4
cmd/dist/fetch.go vendored
View file

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

View file

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