Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of deprecated grpc.Errorf API #1380

Merged
merged 1 commit into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/internal/proto/examplepb/echo_service.pb.gw.go

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

2 changes: 1 addition & 1 deletion protoc-gen-grpc-gateway/descriptor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (p FieldPath) AssignableExpr(msgExpr string) string {
s := `if %s == nil {
%s =&%s{}
} else if _, ok := %s.(*%s); !ok {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s)
return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s)
}`

preparations = append(preparations, fmt.Sprintf(s, components, components, oneofFieldName, components, oneofFieldName, oneofFieldName, components))
Expand Down
1 change: 0 additions & 1 deletion runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ go_test(
"@io_bazel_rules_go//proto/wkt:struct_go_proto",
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//metadata:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
Expand Down
11 changes: 5 additions & 6 deletions runtime/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/internal"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
pb "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -49,13 +48,13 @@ func TestForwardResponseStream(t *testing.T) {
statusCode: http.StatusOK,
}, {
name: "error",
msgs: []msg{{nil, grpc.Errorf(codes.OutOfRange, "400")}},
msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}},
statusCode: http.StatusBadRequest,
}, {
name: "stream_error",
msgs: []msg{
{&pb.SimpleMessage{Id: "One"}, nil},
{nil, grpc.Errorf(codes.OutOfRange, "400")},
{nil, status.Errorf(codes.OutOfRange, "400")},
},
statusCode: http.StatusOK,
}, {
Expand All @@ -70,7 +69,7 @@ func TestForwardResponseStream(t *testing.T) {
name: "response body stream error case",
msgs: []msg{
{fakeReponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil},
{nil, grpc.Errorf(codes.OutOfRange, "400")},
{nil, status.Errorf(codes.OutOfRange, "400")},
},
responseBody: true,
statusCode: http.StatusOK,
Expand Down Expand Up @@ -203,13 +202,13 @@ func TestForwardResponseStreamCustomMarshaler(t *testing.T) {
statusCode: http.StatusOK,
}, {
name: "error",
msgs: []msg{{nil, grpc.Errorf(codes.OutOfRange, "400")}},
msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}},
statusCode: http.StatusBadRequest,
}, {
name: "stream_error",
msgs: []msg{
{&pb.SimpleMessage{Id: "One"}, nil},
{nil, grpc.Errorf(codes.OutOfRange, "400")},
{nil, status.Errorf(codes.OutOfRange, "400")},
},
statusCode: http.StatusOK,
}}
Expand Down