Skip to content

Commit

Permalink
Do not wrap grpc error in the invoker
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Oct 31, 2021
1 parent 060a98c commit 0d2a23d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func SendAll(in interface{}) ClientStreamHandler {
msg := grpcReflect.NewValue(valueOf.Index(i).Interface())

if err := stream.SendMsg(msg); err != nil {
return fmt.Errorf("could not send msg: %w", err)
return err
}
}

Expand Down Expand Up @@ -327,7 +327,7 @@ func receiveMsg(stream grpc.ClientStream, out reflect.Value, msgType reflect.Typ
}

if err != nil {
return reflect.Value{}, fmt.Errorf("could not recv msg: %w", err)
return reflect.Value{}, err
}

out = appendMessage(out, msg)
Expand Down
8 changes: 4 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func TestSendAll(t *testing.T) {
Return(errors.New("send error"))
}),
input: defaultItems(),
expectedError: `could not send msg: send error`,
expectedError: `send error`,
},
{
scenario: "success with a slice of struct",
Expand Down Expand Up @@ -584,7 +584,7 @@ func TestRecvAll(t *testing.T) {
Return(errors.New("recv error"))
}),
output: &[]grpctest.Item{},
expectedError: `could not recv msg: recv error`,
expectedError: `recv error`,
expectedOutput: &[]grpctest.Item{},
},
{
Expand Down Expand Up @@ -656,7 +656,7 @@ func TestSendAndRecvAll_SendError(t *testing.T) {
result := make([]*grpctest.Item, 0)
err := grpcmock.SendAndRecvAll([]*grpctest.Item{{Id: 42}}, &result)(stream)

expected := "could not send msg: send error"
expected := "send error"

assert.EqualError(t, err, expected)
}
Expand All @@ -675,7 +675,7 @@ func TestSendAndRecvAll_RecvError(t *testing.T) {
result := make([]*grpctest.Item, 0)
err := grpcmock.SendAndRecvAll([]*grpctest.Item{}, &result)(stream)

expected := "could not recv msg: recv error"
expected := "recv error"

assert.EqualError(t, err, expected)
}
Expand Down

0 comments on commit 0d2a23d

Please sign in to comment.