mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
23 lines
586 B
Go
23 lines
586 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/errors"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
_ "github.com/zitadel/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)
|
|
}
|