errors.go 1.1 KB

12345678910111213141516171819202122232425262728
  1. package encoding
  2. import "fmt"
  3. // EncodingError is returned from a failure while encoding a Kafka packet. This can happen, for example,
  4. // if you try to encode a string over 2^15 characters in length, since Kafka's encoding rules do not permit that.
  5. type EncodingError string
  6. func (err EncodingError) Error() string {
  7. return "kafka: Could not encode packet. " + string(err)
  8. }
  9. // InsufficientData is returned when decoding and the packet is truncated. This can be expected
  10. // when requesting messages, since as an optimization the server is allowed to return a partial message at the end
  11. // of the message set.
  12. type InsufficientData int
  13. func (err InsufficientData) Error() string {
  14. return fmt.Sprintf("kafka: Insufficient data to decode packet, at least %d more bytes expected.", int(err))
  15. }
  16. // DecodingError is returned when there was an error (other than truncated data) decoding the Kafka broker's response.
  17. // This can be a bad CRC or length field, or any other invalid value.
  18. type DecodingError string
  19. func (err DecodingError) Error() string {
  20. return "kafka: Could not decode packet. " + string(err)
  21. }