Skip to content

Commit

Permalink
Do not return context from client Error hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
iheanyi committed Nov 28, 2019
1 parent 33e3c73 commit 89b596b
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type ClientHooks struct {

// Error hook is called whenever an error occurs during the sending of a request. The Error is passed
// as an argument to the hook.
Error func(context.Context, Error) context.Context
Error func(context.Context, Error)
}

func DefaultClientOptions() ClientOptions {
Expand Down
6 changes: 3 additions & 3 deletions clientcompat/internal/clientcompat/clientcompat.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions example/service.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/twirptest/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,8 @@ func TestClientWithHooks(t *testing.T) {
RequestFinished: func(ctx context.Context) {
requestFinishedCalled = true
},
Error: func(ctx context.Context, err twirp.Error) context.Context {
Error: func(ctx context.Context, err twirp.Error) {
errorCalled = true
return ctx
},
}

Expand Down
6 changes: 3 additions & 3 deletions internal/twirptest/empty_service/empty_service.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/gogo_compat/service.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/google_protobuf_imports/service.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/importable/importable.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/importer/importer.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/importmapping/x/x.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/multiple/multiple1.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/no_package_name/no_package_name.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/proto/proto.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/service.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/snake_case_names/snake_case_names.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/twirptest/source_relative/source_relative.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions protoc-gen-twirp/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,11 @@ func (t *twirp) generateClientHooks() {
t.P(` return h.RequestPrepared(ctx, req)`)
t.P(`}`)
t.P()
t.P(`func callClientError(ctx `, t.pkgs["context"], `.Context, h *`, t.pkgs["twirp"], `.ClientHooks, err `, t.pkgs["twirp"], `.Error) `, t.pkgs["context"], `.Context {`)
t.P(`func callClientError(ctx `, t.pkgs["context"], `.Context, h *`, t.pkgs["twirp"], `.ClientHooks, err `, t.pkgs["twirp"], `.Error) {`)
t.P(` if h == nil || h.Error == nil {`)
t.P(` return ctx`)
t.P(` return`)
t.P(` }`)
t.P(` return h.Error(ctx, err)`)
t.P(` h.Error(ctx, err)`)
t.P(`}`)
}

Expand Down

0 comments on commit 89b596b

Please sign in to comment.