Skip to content

Commit

Permalink
added client side interceptors (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikohobart authored Oct 17, 2024
1 parent 24225e0 commit 264b820
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/intercept/interceptors.go
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)
}
}

0 comments on commit 264b820

Please sign in to comment.