Skip to content

Commit

Permalink
handle unimplemented error using connect-rpc code
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun98 committed Aug 4, 2024
1 parent 742d6d1 commit 781d639
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/yorkie/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"errors"
"fmt"
"runtime"
"strings"

"connectrpc.com/connect"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -119,8 +119,18 @@ func newVersionCmd() *cobra.Command {

if serverErr != nil {
cmd.Printf("Error fetching server version: ")
if strings.Contains(serverErr.Error(), "unimplemented") {
cmd.Printf("The server does not support this operation. You might need to check your server version.\n")

connectErr := new(connect.Error)
if errors.As(serverErr, &connectErr) {
// TODO(hyun98): Find cases where different error cases can occur,
// and display a user-friendly error message for each case.
// Furthermore, it would be good to improve it
// by creating a general-purpose error handling module for rpc communication.
// for example, rpc error handling reference: https://connectrpc.com/docs/go/errors/
switch connectErr.Code() {
case connect.CodeUnimplemented:
cmd.Printf("The server does not support this operation. You might need to check your server version.\n")
}
} else {
cmd.Print(serverErr)
}
Expand Down
1 change: 1 addition & 0 deletions test/bench/tree_editing_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/yorkie-team/yorkie/pkg/document/json"
"github.com/yorkie-team/yorkie/test/helper"
)

func BenchmarkTree(b *testing.B) {
verticesCounts := []int{10000, 20000, 30000}

Expand Down

0 comments on commit 781d639

Please sign in to comment.