package grpctraces

import (
	

	
)

// isError follows OpenTelemetry RPC semantic conventions: clients mark all
// non-OK codes as errors, while servers only mark server-side faults.
func ( codes.Code,  bool) bool {
	if  == codes.OK {
		return false
	}
	if ! {
		return true
	}
	switch  {
	case codes.Unknown,
		codes.DeadlineExceeded,
		codes.Unimplemented,
		codes.Internal,
		codes.Unavailable,
		codes.DataLoss:
		return true
	default:
		return false
	}
}

func ( codes.Code) string {
	switch  {
	case codes.OK:
		return "OK"
	case codes.Canceled:
		return "CANCELLED" //nolint:misspell // canonical gRPC status name
	case codes.Unknown:
		return "UNKNOWN"
	case codes.InvalidArgument:
		return "INVALID_ARGUMENT"
	case codes.DeadlineExceeded:
		return "DEADLINE_EXCEEDED"
	case codes.NotFound:
		return "NOT_FOUND"
	case codes.AlreadyExists:
		return "ALREADY_EXISTS"
	case codes.PermissionDenied:
		return "PERMISSION_DENIED"
	case codes.ResourceExhausted:
		return "RESOURCE_EXHAUSTED"
	case codes.FailedPrecondition:
		return "FAILED_PRECONDITION"
	case codes.Aborted:
		return "ABORTED"
	case codes.OutOfRange:
		return "OUT_OF_RANGE"
	case codes.Unimplemented:
		return "UNIMPLEMENTED"
	case codes.Internal:
		return "INTERNAL"
	case codes.Unavailable:
		return "UNAVAILABLE"
	case codes.DataLoss:
		return "DATA_LOSS"
	case codes.Unauthenticated:
		return "UNAUTHENTICATED"
	default:
		return strconv.FormatUint(uint64(), 10)
	}
}