Skip to content

Commit

Permalink
Alternative fix: keep back compat with interceptor contract
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrom committed Nov 28, 2024
1 parent facbe19 commit 6729bd4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func NewClient[Req, Res any](httpClient HTTPClient, url string, options ...Clien
response, err := receiveUnaryResponse[Res](conn, config.Initializer)
if err != nil {
_ = conn.CloseResponse()
return response, err
return nil, err
}
return response, conn.CloseResponse()
})
Expand All @@ -110,7 +110,7 @@ func NewClient[Req, Res any](httpClient HTTPClient, url string, options ...Clien
request.peer = client.protocolClient.Peer()
protocolClient.WriteRequestHeader(StreamTypeUnary, request.Header())
response, err := unaryFunc(ctx, request)
if err != nil {
if err != nil || response == nil {
return nil, err
}
typed, ok := response.(*Response[Res])
Expand Down
2 changes: 1 addition & 1 deletion client_error_handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestClientErrorHandling(t *testing.T) {

// errorHidingInterceptor is a simple interceptor that hides errors based on
// some criteria (in this case, if the error is a CodeCanceled error). It is
// use to reproduce an issue with error handling in the client, where the
// used to reproduce an issue with error handling in the client, where the
// type information is lost between unaryFunc and client.callUnary.
type errorHidingInterceptor struct{}

Expand Down

0 comments on commit 6729bd4

Please sign in to comment.