Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
error_message: remove stack error message (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored Jun 18, 2020
1 parent 05fc731 commit fb52a1f
Show file tree
Hide file tree
Showing 29 changed files with 98 additions and 121 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
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
5 changes: 2 additions & 3 deletions dm/ctl/master/list_member.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/dm/ctl/common"
Expand Down Expand Up @@ -73,7 +72,7 @@ func listMemberFunc(cmd *cobra.Command, _ []string) {

leader, master, worker, err := convertListMemberType(cmd)
if err != nil {
common.PrintLines("%s", errors.ErrorStack(err))
common.PrintLines("%v", err)
}

ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -88,7 +87,7 @@ func listMemberFunc(cmd *cobra.Command, _ []string) {
})

if err != nil {
common.PrintLines("list member failed, error:\n%v", errors.ErrorStack(err))
common.PrintLines("list member failed, error:\n%v", err)
return
}
common.PrettyPrintResponse(resp)
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
7 changes: 4 additions & 3 deletions dm/ctl/master/offline_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) {

offlineType, err := convertOfflineMemberType(cmd)
if err != nil {
common.PrintLines("get offline type failed, error:\n%v", errors.ErrorStack(err))
common.PrintLines("get offline type failed, error:\n%v", err)
return
}
name, err := cmd.Flags().GetString("name")
if err != nil {
common.PrintLines("get offline name failed, error:\n%v", errors.ErrorStack(err))
common.PrintLines("get offline name failed, error:\n%v", err)
return
} else if name == "" {
common.PrintLines("a member name must be specified")
Expand All @@ -85,11 +85,12 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) {
Name: name,
})
if err != nil {
common.PrintLines("offline member failed, error:\n%v", errors.ErrorStack(err))
common.PrintLines("offline member failed, error:\n%v", err)
return
}
if !resp.Result {
common.PrintLines("offline member failed:\n%v", resp.Msg)
return
}
common.PrettyPrintResponse(resp)
}
3 changes: 1 addition & 2 deletions dm/ctl/master/operate_leader.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/dm/ctl/common"
Expand Down Expand Up @@ -70,7 +69,7 @@ func operateLeaderFunc(cmd *cobra.Command, _ []string) {
Op: op,
})
if err != nil {
common.PrintLines("fail to operate leader:\n%v", errors.ErrorStack(err))
common.PrintLines("fail to operate leader:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/operate_source.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 Down Expand Up @@ -59,7 +58,7 @@ func operateSourceFunc(cmd *cobra.Command, _ []string) {
configFile := cmd.Flags().Arg(1)
content, err := common.GetFileContent(configFile)
if err != nil {
common.PrintLines("get file content error:\n%v", errors.ErrorStack(err))
common.PrintLines("get file content error:\n%v", err)
return
}
ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -77,7 +76,7 @@ func operateSourceFunc(cmd *cobra.Command, _ []string) {
Op: op,
})
if err != nil {
common.PrintLines("can not update task:\n%v", errors.ErrorStack(err))
common.PrintLines("can not update task:\n%v", err)
return
}

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) {

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

resp, err := common.OperateRelay(pb.RelayOp_PauseRelay, sources)
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) {

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

resp, err := common.OperateTask(pb.TaskOp_Pause, name, sources)
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) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
fmt.Println(errors.ErrorStack(err))
common.PrintLines("%v", err)
return
}
if len(sources) == 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) {

sources, err := common.GetSourceArgs(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(sources) > 0 {
common.PrintLines("sources: %v", sources)
}
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) {

sources, err := common.GetSourceArgs(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) {
Sources: sources,
})
if err != nil {
common.PrintLines("can not query %s task's status(in sources %v):\n%s", taskName, sources, terror.Message(err))
common.PrintLines("can not query %s task's status(in sources %v):\n%v", taskName, sources, err)
return
}

more, err := cmd.Flags().GetBool("more")
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%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) {

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

resp, err := common.OperateRelay(pb.RelayOp_ResumeRelay, sources)
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) {

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

resp, err := common.OperateTask(pb.TaskOp_Resume, name, sources)
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) {

sources, err := common.GetSourceArgs(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) {
Sources: sources,
})
if err != nil {
common.PrintLines("can not show DDL locks for task %s and sources %v:\n%s", taskName, sources, errors.ErrorStack(err))
common.PrintLines("can not show DDL locks for task %s and sources %v:\n%v", taskName, sources, err)
return
}

Expand Down
Loading

0 comments on commit fb52a1f

Please sign in to comment.