public KafkaConsumeException(string message, ErrorMapping errorCode)
     : base(message, errorCode)
 {
 }
 public KafkaClientException(string message, ErrorMapping errorCode)
     : this(message)
 {
     this.ErrorCode = errorCode;
 }
 public TopicMetadata(string topic, IEnumerable<PartitionMetadata> partitionsMetadata, ErrorMapping error)
 {
     this.Topic = topic;
     this.PartitionsMetadata = partitionsMetadata;
     Error = error;
 }
 public KafkaException(string message, ErrorMapping errorCode)
     : base(message + GetMessage((short)errorCode))
 {
     ErrorCode = (short)errorCode;
 }
 public KafkaException(ErrorMapping errorCode)
     : base(GetMessage((short)errorCode))
 {
     ErrorCode = (short)errorCode;
 }
        public static string GetMessage(ErrorMapping error)
        {
            switch (error)
            {
                case ErrorMapping.NoError:
                    return "NoError";
                case ErrorMapping.OffsetOutOfRangeCode:
                    return "Offset out of range.";
                case ErrorMapping.InvalidMessageCode:
                    return "Invalid message.";
                case ErrorMapping.MessagesizeTooLargeCode:
                    return "Message size too large.";
                case ErrorMapping.UnknownTopicOrPartitionCode:
                    return "Unknown topic or partition.";
                case ErrorMapping.InvalidFetchSizeCode:
                    return "Invalid fetch size passed.";
                case ErrorMapping.LeaderNotAvailableCode:
                    return "Leader not found for given topic/partition.";
                case ErrorMapping.NotLeaderForPartitionCode:
                    return "This error is thrown if the client attempts to send messages to a replica that is not the leader for some partition. It indicates that the clients metadata is out of date.";
                case ErrorMapping.RequestTimedOutCode:
                    return "This error is thrown if the request exceeds the user-specified time limit in the request.";
                case ErrorMapping.BrokerNotAvailableCode:
                    return "This is not a client facing error and is used mostly by tools when a broker is not alive.";
                case ErrorMapping.ReplicaNotAvailableCode:
                    return "If replica is expected on a broker, but is not.";
                case ErrorMapping.StaleControllerEpochCode:
                    return "Internal error code for broker-to-broker communication.";
                case ErrorMapping.OffsetMetadataTooLargeCode:
                    return "The server has a configurable maximum message size to avoid unbounded memory allocation. This error is thrown if the client attempt to produce a message larger than this maximum.";
                case ErrorMapping.StaleLeaderEpochCode:
                    return "StaleLeaderEpochCode";
                case ErrorMapping.OffsetsLoadInProgressCode:
                    return "The broker returns this error code for an offset fetch request if it is still loading offsets (after a leader change for that offsets topic partition).";
                case ErrorMapping.ConsumerCoordinatorNotAvailableCode:
                    return "The broker returns this error code for consumer metadata requests or offset commit requests if the offsets topic has not yet been created.";
                case ErrorMapping.NotCoordinatorForConsumerCode:
                    return "The broker returns this error code if it receives an offset fetch or commit request for a consumer group that it is not a coordinator for.";
            }

            return "Unknown Error.";
        }