func()

in exponential/helpers/grpc/grpc.go [157:178]


func (t *Transformer) isGRPCErr(err error) (bool, codes.Code) {
	// The gRPC status package is actually a wrapper around an internal status package. While Status is exposed
	// through this package, the Error type is not. So there is no great way to know if
	// we have a grpc Error type. That is unless we want to use the compiler linkname directive to get
	// at the internal status package. So instead we look to see if codes.Unknown is returned, which
	// is what happens when we have a non-gRPC error given to code. But since a person can set that too,
	// we look to see if the error has a GRPCStatus method. If it does, then it is a gRPC error.
	// The tests should protect us in case they change the internal Error type to remove GRPCStatus.
	code := status.Code(err)
	switch code {
	case codes.Unknown:
		// We look to see if the error has a GRPCStatus method. If it does, then it is a gRPC error.
		// This is not the greatest, but it is the best we can do without using the compiler directive.
		if _, ok := reflect.TypeOf(err).MethodByName("GRPCStatus"); ok {
			return true, code
		}
		return false, code
	case codes.OK:
		return false, code
	}
	return true, code
}