From 01eb1bddea13908b063e79935d76cd5922f6da14 Mon Sep 17 00:00:00 2001 From: Adphi Date: Thu, 24 Mar 2022 13:53:05 +0100 Subject: [PATCH] errors: remove {Code}D and {Code}F methods Signed-off-by: Adphi --- errors/errors.go | 84 ------------------------------------------------ 1 file changed, 84 deletions(-) diff --git a/errors/errors.go b/errors/errors.go index 9d7a574..6351592 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -11,129 +11,45 @@ import ( func InvalidArgument(err error) error { return status.Error(codes.InvalidArgument, err.Error()) } -func InvalidArgumentF(msg string, args ...interface{}) error { - return status.Errorf(codes.InvalidArgument, msg, args...) -} -func InvalidArgumentD(err error, details ...proto.Message) error { - return statusErr(codes.InvalidArgument, err, details...) -} func DeadlineExceeded(err error) error { return status.Error(codes.DeadlineExceeded, err.Error()) } -func DeadlineExceededF(msg string, args ...interface{}) error { - return status.Errorf(codes.DeadlineExceeded, msg, args...) -} -func DeadlineExceededD(err error, details ...proto.Message) error { - return statusErr(codes.DeadlineExceeded, err, details...) -} func NotFound(err error) error { return status.Error(codes.NotFound, err.Error()) } -func NotFoundF(msg string, args ...interface{}) error { - return status.Errorf(codes.NotFound, msg, args...) -} -func NotFoundD(err error, details ...proto.Message) error { - return statusErr(codes.NotFound, err, details...) -} func AlreadyExists(err error) error { return status.Error(codes.AlreadyExists, err.Error()) } -func AlreadyExistsF(msg string, args ...interface{}) error { - return status.Errorf(codes.AlreadyExists, msg, args...) -} -func AlreadyExistsD(err error, details ...proto.Message) error { - return statusErr(codes.AlreadyExists, err, details...) -} func PermissionDenied(err error) error { return status.Error(codes.PermissionDenied, err.Error()) } -func PermissionDeniedF(msg string, args ...interface{}) error { - return status.Errorf(codes.PermissionDenied, msg, args...) -} -func PermissionDeniedD(err error, details ...proto.Message) error { - return statusErr(codes.PermissionDenied, err, details...) -} func ResourceExhausted(err error) error { return status.Error(codes.ResourceExhausted, err.Error()) } -func ResourceExhaustedF(msg string, args ...interface{}) error { - return status.Errorf(codes.ResourceExhausted, msg, args...) -} -func ResourceExhaustedD(err error, details ...proto.Message) error { - return statusErr(codes.ResourceExhausted, err, details...) -} func FailedPrecondition(err error) error { return status.Error(codes.FailedPrecondition, err.Error()) } -func FailedPreconditionF(msg string, args ...interface{}) error { - return status.Errorf(codes.FailedPrecondition, msg, args...) -} -func FailedPreconditionD(err error, details ...proto.Message) error { - return statusErr(codes.FailedPrecondition, err, details...) -} func Aborted(err error) error { return status.Error(codes.Aborted, err.Error()) } -func AbortedF(msg string, args ...interface{}) error { - return status.Errorf(codes.Aborted, msg, args...) -} -func AbortedD(err error, details ...proto.Message) error { - return statusErr(codes.Aborted, err, details...) -} func OutOfRange(err error) error { return status.Error(codes.OutOfRange, err.Error()) } -func OutOfRangeF(msg string, args ...interface{}) error { - return status.Errorf(codes.OutOfRange, msg, args...) -} -func OutOfRangeD(err error, details ...proto.Message) error { - return statusErr(codes.OutOfRange, err, details...) -} func Unimplemented(err error) error { return status.Error(codes.Unimplemented, err.Error()) } -func UnimplementedF(msg string, args ...interface{}) error { - return status.Errorf(codes.Unimplemented, msg, args...) -} -func UnimplementedD(err error, details ...proto.Message) error { - return statusErr(codes.Unimplemented, err, details...) -} func Internal(err error) error { return status.Error(codes.Internal, err.Error()) } -func InternalF(msg string, args ...interface{}) error { - return status.Errorf(codes.Internal, msg, args...) -} -func InternalD(err error, details ...proto.Message) error { - return statusErr(codes.Internal, err, details...) -} func Unavailable(err error) error { return status.Error(codes.Unavailable, err.Error()) } -func UnavailableF(msg string, args ...interface{}) error { - return status.Errorf(codes.Unavailable, msg, args...) -} -func UnavailableD(err error, details ...proto.Message) error { - return statusErr(codes.Unavailable, err, details...) -} func DataLoss(err error) error { return status.Error(codes.DataLoss, err.Error()) } -func DataLossF(msg string, args ...interface{}) error { - return status.Errorf(codes.DataLoss, msg, args...) -} -func DataLossD(err error, details ...proto.Message) error { - return statusErr(codes.DataLoss, err, details...) -} func Unauthenticated(err error) error { return status.Error(codes.Unauthenticated, err.Error()) } -func UnauthenticatedF(msg string, args ...interface{}) error { - return status.Errorf(codes.Unauthenticated, msg, args...) -} -func UnauthenticatedD(err error, details ...proto.Message) error { - return statusErr(codes.Unauthenticated, err, details...) -} func statusErr(code codes.Code, err error, details ...proto.Message) error { return status.FromProto(&status2.Status{Code: int32(code), Message: err.Error(), Details: makeDetails(details...)}).Err() }