errors: remove {Code}D and {Code}F methods

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2022-03-24 13:53:05 +01:00
parent 0754c0de00
commit 01eb1bddea
Signed by: adphi
GPG Key ID: 46BE4062DB2397FF

View File

@ -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()
}