zitadel/internal/api/grpc/server/middleware/error_interceptor.go
Fabi 7295383621
fix: translation (#647)
* fix: translation

* fix: translation

* fix: translation

* fix: remove unused code

* fix: log err
2020-08-28 09:44:43 +02:00

22 lines
579 B
Go

package middleware
import (
"context"
"github.com/caos/zitadel/internal/api/grpc/errors"
"google.golang.org/grpc"
_ "github.com/caos/zitadel/internal/statik"
)
func ErrorHandler() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
return toGRPCError(ctx, req, handler)
}
}
func toGRPCError(ctx context.Context, req interface{}, handler grpc.UnaryHandler) (interface{}, error) {
resp, err := handler(ctx, req)
return resp, errors.CaosToGRPCError(ctx, err)
}