Skip to content

Commit 690734d

Browse files
authored
Remove usage of deprecated grpc.Errorf API (#1380)
1 parent f9f8a34 commit 690734d

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

examples/internal/proto/examplepb/echo_service.pb.gw.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protoc-gen-grpc-gateway/descriptor/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (p FieldPath) AssignableExpr(msgExpr string) string {
323323
s := `if %s == nil {
324324
%s =&%s{}
325325
} else if _, ok := %s.(*%s); !ok {
326-
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s)
326+
return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s)
327327
}`
328328

329329
preparations = append(preparations, fmt.Sprintf(s, components, components, oneofFieldName, components, oneofFieldName, oneofFieldName, components))

runtime/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ go_test(
7878
"@io_bazel_rules_go//proto/wkt:struct_go_proto",
7979
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
8080
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
81-
"@org_golang_google_grpc//:go_default_library",
8281
"@org_golang_google_grpc//codes:go_default_library",
8382
"@org_golang_google_grpc//metadata:go_default_library",
8483
"@org_golang_google_grpc//status:go_default_library",

runtime/handler_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/grpc-ecosystem/grpc-gateway/internal"
1313
"github.com/grpc-ecosystem/grpc-gateway/runtime"
1414
pb "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb"
15-
"google.golang.org/grpc"
1615
"google.golang.org/grpc/codes"
1716
"google.golang.org/grpc/status"
1817
)
@@ -49,13 +48,13 @@ func TestForwardResponseStream(t *testing.T) {
4948
statusCode: http.StatusOK,
5049
}, {
5150
name: "error",
52-
msgs: []msg{{nil, grpc.Errorf(codes.OutOfRange, "400")}},
51+
msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}},
5352
statusCode: http.StatusBadRequest,
5453
}, {
5554
name: "stream_error",
5655
msgs: []msg{
5756
{&pb.SimpleMessage{Id: "One"}, nil},
58-
{nil, grpc.Errorf(codes.OutOfRange, "400")},
57+
{nil, status.Errorf(codes.OutOfRange, "400")},
5958
},
6059
statusCode: http.StatusOK,
6160
}, {
@@ -70,7 +69,7 @@ func TestForwardResponseStream(t *testing.T) {
7069
name: "response body stream error case",
7170
msgs: []msg{
7271
{fakeReponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil},
73-
{nil, grpc.Errorf(codes.OutOfRange, "400")},
72+
{nil, status.Errorf(codes.OutOfRange, "400")},
7473
},
7574
responseBody: true,
7675
statusCode: http.StatusOK,
@@ -203,13 +202,13 @@ func TestForwardResponseStreamCustomMarshaler(t *testing.T) {
203202
statusCode: http.StatusOK,
204203
}, {
205204
name: "error",
206-
msgs: []msg{{nil, grpc.Errorf(codes.OutOfRange, "400")}},
205+
msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}},
207206
statusCode: http.StatusBadRequest,
208207
}, {
209208
name: "stream_error",
210209
msgs: []msg{
211210
{&pb.SimpleMessage{Id: "One"}, nil},
212-
{nil, grpc.Errorf(codes.OutOfRange, "400")},
211+
{nil, status.Errorf(codes.OutOfRange, "400")},
213212
},
214213
statusCode: http.StatusOK,
215214
}}

0 commit comments

Comments
 (0)