2020-03-24 14:15:01 +01:00
|
|
|
package middleware
|
2020-03-23 07:01:59 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
2020-03-24 14:15:01 +01:00
|
|
|
|
|
|
|
grpc_util "github.com/caos/zitadel/internal/api/grpc"
|
2020-03-23 07:01:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func ErrorHandler() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
|
|
resp, err := handler(ctx, req)
|
2020-03-24 14:15:01 +01:00
|
|
|
return resp, grpc_util.CaosToGRPCError(err)
|
2020-03-23 07:01:59 +01:00
|
|
|
}
|
|
|
|
}
|