Skip to content

Commit 69d4a0d

Browse files
committed
StatusCode -> Code
1 parent a7ce869 commit 69d4a0d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ func main() {
4949
grpcerrors.WithNotWrappedErrorHandler(func(c context.Context, err error) error {
5050
// WithNotWrappedErrorHandler handles an error not wrapped with `*fail.Error`.
5151
// A handler function should wrap received error with `*fail.Error`.
52-
return fail.Wrap(err, fail.WithStatusCode(CodeNotWrapped))
52+
return fail.Wrap(err, fail.WithCode(CodeNotWrapped))
5353
}),
5454
grpcerrors.WithReportableErrorHandler(func(c context.Context, err *fail.Error) error {
5555
// WithReportableErrorHandler handles an erorr annotated with the reportability.
5656
// You reports to an external service if necessary.
5757
// And you can attach request contexts to error reports.
5858
return err
5959
}),
60-
grpcerrors.WithStatusCodeMap(grpcCodeByYourCode),
60+
grpcerrors.WithCodeMap(grpcCodeByYourCode),
6161
}
6262

6363
s := grpc.NewServer(

handlers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ func WithReportableErrorHandler(f FailHandlerFunc) interface {
9696
// CodeMap maps any status codes to gRPC's `codes.Code`s.
9797
type CodeMap map[interface{}]codes.Code
9898

99-
// WithStatusCodeMap returns a new error handler function for mapping status codes to gRPC's one.
100-
func WithStatusCodeMap(m CodeMap) interface {
99+
// WithCodeMap returns a new error handler function for mapping status codes to gRPC's one.
100+
func WithCodeMap(m CodeMap) interface {
101101
UnaryServerErrorHandler
102102
StreamServerErrorHandler
103103
} {
@@ -112,8 +112,8 @@ func WithStatusCodeMap(m CodeMap) interface {
112112
// CodeMapFunc returns gRPC's `codes.Code`s from given any codes.
113113
type CodeMapFunc func(code interface{}) codes.Code
114114

115-
// WithStatusCodeMapper returns a new error handler function for mapping status codes to gRPC's one with given function.
116-
func WithStatusCodeMapper(mapFn CodeMapFunc) interface {
115+
// WithCodeMapper returns a new error handler function for mapping status codes to gRPC's one with given function.
116+
func WithCodeMapper(mapFn CodeMapFunc) interface {
117117
UnaryServerErrorHandler
118118
StreamServerErrorHandler
119119
} {

interceptors_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ func Test_UnaryServerInterceptor(t *testing.T) {
164164
return err
165165
}),
166166
WithGrpcStatusUnwrapper(),
167-
WithStatusCodeMap(CodeMap{50: codes.PermissionDenied}),
168-
WithStatusCodeMapper(func(c interface{}) codes.Code {
167+
WithCodeMap(CodeMap{50: codes.PermissionDenied}),
168+
WithCodeMapper(func(c interface{}) codes.Code {
169169
if c == 52 {
170170
return codes.InvalidArgument
171171
}

0 commit comments

Comments
 (0)