Skip to content

Commit

Permalink
error_message: remove stack error message (pingcap#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Jun 18, 2020
1 parent 33c7ede commit 5e81b85
Show file tree
Hide file tree
Showing 26 changed files with 88 additions and 113 deletions.
6 changes: 3 additions & 3 deletions dm/ctl/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func PrintLines(format string, a ...interface{}) {
func PrettyPrintResponse(resp proto.Message) {
s, err := marshResponseToString(resp)
if err != nil {
PrintLines(errors.ErrorStack(err))
PrintLines("%v", err)
} else {
fmt.Println(s)
}
Expand All @@ -82,7 +82,7 @@ func PrettyPrintResponse(resp proto.Message) {
func PrettyPrintInterface(resp interface{}) {
s, err := json.MarshalIndent(resp, "", " ")
if err != nil {
PrintLines(errors.ErrorStack(err))
PrintLines("%v", err)
} else {
fmt.Println(string(s))
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func PrettyPrintResponseWithCheckTask(resp proto.Message, subStr string) bool {
}

if err != nil {
fmt.Println(errors.ErrorStack(err))
PrintLines("%v", err)
} else {
// add indent to make it prettily.
replacedStr = strings.Replace(replacedStr, "detail: {", " \tdetail: {", 1)
Expand Down
11 changes: 5 additions & 6 deletions dm/ctl/master/break_ddl_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"

"github.com/pingcap/errors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -49,7 +48,7 @@ func breakDDLLockFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
fmt.Println(errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}
if len(workers) == 0 {
Expand All @@ -59,19 +58,19 @@ func breakDDLLockFunc(cmd *cobra.Command, _ []string) {

removeLockID, err := cmd.Flags().GetString("remove-id")
if err != nil {
fmt.Println(errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}

exec, err := cmd.Flags().GetBool("exec")
if err != nil {
fmt.Println(errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}

skip, err := cmd.Flags().GetBool("skip")
if err != nil {
fmt.Println(errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -96,7 +95,7 @@ func breakDDLLockFunc(cmd *cobra.Command, _ []string) {
SkipDDL: skip,
})
if err != nil {
common.PrintLines("can not break DDL lock (in workers %v):\n%s", workers, errors.ErrorStack(err))
common.PrintLines("can not break DDL lock (in workers %v):\n%v", workers, err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/check_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"context"
"os"

"github.com/pingcap/errors"
"github.com/spf13/cobra"

"github.com/pingcap/dm/checker"
Expand All @@ -44,7 +43,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) {
}
content, err := common.GetFileContent(cmd.Flags().Arg(0))
if err != nil {
common.PrintLines("get file content error:\n%v", errors.ErrorStack(err))
common.PrintLines("get file content error:\n%v", err)
return
}

Expand All @@ -57,7 +56,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) {
Task: string(content),
})
if err != nil {
common.PrintLines("fail to check task:\n%v", errors.ErrorStack(err))
common.PrintLines("fail to check task:\n%v", err)
return
}

Expand Down
3 changes: 1 addition & 2 deletions dm/ctl/master/migrate_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"os"
"strconv"

"github.com/pingcap/errors"
"github.com/spf13/cobra"
"go.uber.org/zap"

Expand Down Expand Up @@ -49,7 +48,7 @@ func migrateRelayFunc(cmd *cobra.Command, _ []string) {
binlogName := cmd.Flags().Arg(1)
binlogPos, err := strconv.Atoi(cmd.Flags().Arg(2))
if err != nil {
common.PrintLines(errors.ErrorStack(err))
common.PrintLines("%v", err)
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/pause_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"fmt"
"os"

"github.com/pingcap/errors"
"github.com/spf13/cobra"

"github.com/pingcap/dm/dm/ctl/common"
Expand All @@ -44,7 +43,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}
if len(workers) == 0 {
Expand All @@ -54,7 +53,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) {

resp, err := common.OperateRelay(pb.RelayOp_PauseRelay, workers)
if err != nil {
common.PrintLines("can not pause relay unit:\n%v", errors.ErrorStack(err))
common.PrintLines("can not pause relay unit:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/pause_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package master
import (
"os"

"github.com/pingcap/errors"
"github.com/spf13/cobra"

"github.com/pingcap/dm/dm/ctl/common"
Expand Down Expand Up @@ -44,13 +43,13 @@ func pauseTaskFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}

resp, err := common.OperateTask(pb.TaskOp_Pause, name, workers)
if err != nil {
common.PrintLines("can not pause task %s:\n%v", name, errors.ErrorStack(err))
common.PrintLines("can not pause task %s:\n%v", name, err)
return
}

Expand Down
4 changes: 2 additions & 2 deletions dm/ctl/master/purge_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
fmt.Println(errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}
if len(workers) == 0 {
Expand Down Expand Up @@ -145,7 +145,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) {
SubDir: subDir,
})
if err != nil {
common.PrintLines("can not purge relay log files: \n%s", errors.ErrorStack(err))
common.PrintLines("can not purge relay log files: \n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/query_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"

"github.com/spf13/cobra"
)
Expand All @@ -45,7 +44,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -64,7 +63,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) {
if len(workers) > 0 {
common.PrintLines("workers: %v", workers)
}
common.PrintLines("error: %s", terror.Message(err))
common.PrintLines("error: %v", err)
return
}

Expand Down
7 changes: 3 additions & 4 deletions dm/ctl/master/query_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

const stageError = "Error"
Expand Down Expand Up @@ -61,7 +60,7 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -73,13 +72,13 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) {
Workers: workers,
})
if err != nil {
common.PrintLines("can not query %s task's status(in workers %v):\n%s", taskName, workers, terror.Message(err))
common.PrintLines("can not query %s task's status(in workers %v):\n%v", taskName, workers, err)
return
}

more, err := cmd.Flags().GetBool("more")
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand Down
3 changes: 1 addition & 2 deletions dm/ctl/master/refresh_worker_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"

"github.com/pingcap/errors"
"github.com/spf13/cobra"
)

Expand All @@ -47,7 +46,7 @@ func refreshWorkerTasksFunc(cmd *cobra.Command, _ []string) {
cli := common.MasterClient()
resp, err := cli.RefreshWorkerTasks(ctx, &pb.RefreshWorkerTasksRequest{})
if err != nil {
common.PrintLines("can not refresh workerTasks:\n%v", errors.ErrorStack(err))
common.PrintLines("can not refresh workerTasks:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/resume_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"fmt"
"os"

"github.com/pingcap/errors"
"github.com/spf13/cobra"

"github.com/pingcap/dm/dm/ctl/common"
Expand All @@ -44,7 +43,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}
if len(workers) == 0 {
Expand All @@ -54,7 +53,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) {

resp, err := common.OperateRelay(pb.RelayOp_ResumeRelay, workers)
if err != nil {
common.PrintLines("can not resume relay unit:\n%v", errors.ErrorStack(err))
common.PrintLines("can not resume relay unit:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/resume_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package master
import (
"os"

"github.com/pingcap/errors"
"github.com/spf13/cobra"

"github.com/pingcap/dm/dm/ctl/common"
Expand Down Expand Up @@ -44,13 +43,13 @@ func resumeTaskFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}

resp, err := common.OperateTask(pb.TaskOp_Resume, name, workers)
if err != nil {
common.PrintLines("can not resume task %s:\n%v", name, errors.ErrorStack(err))
common.PrintLines("can not resume task %s:\n%v", name, err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/show_ddl_locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"

"github.com/pingcap/errors"
"github.com/spf13/cobra"
)

Expand All @@ -45,7 +44,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -57,7 +56,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) {
Workers: workers,
})
if err != nil {
common.PrintLines("can not show DDL locks for task %s and workers %v:\n%s", taskName, workers, errors.ErrorStack(err))
common.PrintLines("can not show DDL locks for task %s and workers %v:\n%v", taskName, workers, err)
return
}

Expand Down
9 changes: 4 additions & 5 deletions dm/ctl/master/sql_inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"os"
"strings"

"github.com/pingcap/errors"
"github.com/spf13/cobra"

"github.com/pingcap/dm/dm/ctl/common"
Expand All @@ -45,7 +44,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) {

workers, err := common.GetWorkerArgs(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}
if len(workers) != 1 {
Expand All @@ -62,13 +61,13 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) {
extraArgs := cmd.Flags().Args()[1:]
realSQLs, err := common.ExtractSQLsFromArgs(extraArgs)
if err != nil {
common.PrintLines("check sqls err %s", errors.ErrorStack(err))
common.PrintLines("check sqls err %v", err)
return
}
for _, sql := range realSQLs {
isDDL, err2 := common.IsDDL(sql)
if err2 != nil {
common.PrintLines("check sql err %s", errors.ErrorStack(err2))
common.PrintLines("check sql err %v", err2)
return
}
if !isDDL {
Expand All @@ -87,7 +86,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) {
Worker: workers[0],
})
if err != nil {
common.PrintLines("can not inject sql:\n%v", errors.ErrorStack(err))
common.PrintLines("can not inject sql:\n%v", err)
return
}

Expand Down
Loading

0 comments on commit 5e81b85

Please sign in to comment.