Skip to content

Commit

Permalink
fix : add error wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu22e committed Jul 30, 2023
1 parent cd07b13 commit 795e100
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/yorkie/context/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func newListCommand() *cobra.Command {
Short: "List all contexts from configuration",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/yorkie/context/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func newSetContextCmd() *cobra.Command {
Short: "Set the current global flags as the context",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/yorkie/document/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package document
import (
"context"
"errors"
"fmt"
"time"

"github.com/jedib0t/go-pretty/v6/table"
Expand All @@ -42,7 +43,7 @@ func newListCommand() *cobra.Command {
Short: "List all documents in the project",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/yorkie/document/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package document
import (
"context"
"errors"
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -38,7 +39,7 @@ func newRemoveCommand() *cobra.Command {
Example: "yorkie document remove sample-project sample-document [options]",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/yorkie/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"context"
"errors"
"fmt"

"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
Expand All @@ -41,7 +42,7 @@ func newHistoryCmd() *cobra.Command {
Short: "Show the history of a document",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/yorkie/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -37,7 +38,7 @@ func newLoginCmd() *cobra.Command {
Short: "Log in to the Yorkie server",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/yorkie/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func newLogoutCmd() *cobra.Command {
Short: "Log out from the Yorkie server",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/yorkie/project/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newCreateCommand() *cobra.Command {
Example: "yorkie project create sample-project",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/yorkie/project/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package project

import (
"context"
"fmt"
"time"

"github.com/jedib0t/go-pretty/v6/table"
Expand All @@ -35,7 +36,7 @@ func newListCommand() *cobra.Command {
Short: "List all projects",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/yorkie/project/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newUpdateCommand() *cobra.Command {
Example: "yorkie project update name [options]",
PreRunE: func(cmd *cobra.Command, args []string) error {
if err := viper.ReadInConfig(); err != nil {
return err
return fmt.Errorf("failed to read in config: %w", err)
}
return nil
},
Expand Down

0 comments on commit 795e100

Please sign in to comment.