From a58d7dc11bc37ff0938fe775153dd3b9cb10ffa5 Mon Sep 17 00:00:00 2001 From: Michael Holloway Date: Sat, 3 Jun 2023 10:09:03 -0700 Subject: [PATCH 1/2] Add status.Errorf --- grpc/status/status.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grpc/status/status.go b/grpc/status/status.go index 7c18eb9..99a7cb2 100644 --- a/grpc/status/status.go +++ b/grpc/status/status.go @@ -11,6 +11,10 @@ func Error(c codes.Code, msg string) error { return extgrpc.WrapWithGrpcCode(errors.New(msg), c) } +func Errorf(c codes.Code, format string, args ...interface{}) error { + return extgrpc.WrapWithGrpcCode(errors.Errorf(format, args...), c) +} + func WrapErr(c codes.Code, msg string, err error) error { return extgrpc.WrapWithGrpcCode(errors.WrapWithDepth(1, err, msg), c) } From d4f6f5e8306e7aa51d465b5e5ab1f5281f913f5c Mon Sep 17 00:00:00 2001 From: Michael Holloway Date: Sun, 4 Jun 2023 20:12:38 -0700 Subject: [PATCH 2/2] Add WrapErrf --- grpc/status/status.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grpc/status/status.go b/grpc/status/status.go index 99a7cb2..3a248e9 100644 --- a/grpc/status/status.go +++ b/grpc/status/status.go @@ -12,13 +12,17 @@ func Error(c codes.Code, msg string) error { } func Errorf(c codes.Code, format string, args ...interface{}) error { - return extgrpc.WrapWithGrpcCode(errors.Errorf(format, args...), c) + return extgrpc.WrapWithGrpcCode(errors.Newf(format, args...), c) } func WrapErr(c codes.Code, msg string, err error) error { return extgrpc.WrapWithGrpcCode(errors.WrapWithDepth(1, err, msg), c) } +func WrapErrf(c codes.Code, err error, format string, args ...interface{}) error { + return extgrpc.WrapWithGrpcCode(errors.WrapWithDepthf(1, err, format, args...), c) +} + func Code(err error) codes.Code { return extgrpc.GetGrpcCode(err) }