-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added client side interceptors (#308)
- Loading branch information
1 parent
24225e0
commit 264b820
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Package intercept provides gRPC interceptors for MOCStack clients. | ||
package intercept | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/microsoft/moc/pkg/errors" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
// NewErrorParsingInterceptor transforms grpc errors to moc errors | ||
func NewErrorParsingInterceptor() grpc.UnaryClientInterceptor { | ||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { | ||
err := invoker(ctx, method, req, reply, cc, opts...) | ||
return errors.ParseGRPCError(err) | ||
} | ||
} |