attributes_debug.go 620 B

12345678910111213141516171819202122232425262728293031323334
  1. //go:build debug
  2. // +build debug
  3. package stun
  4. import "fmt"
  5. // AttrOverflowErr occurs when len(v) > Max.
  6. type AttrOverflowErr struct {
  7. Type AttrType
  8. Max int
  9. Got int
  10. }
  11. func (e AttrOverflowErr) Error() string {
  12. return fmt.Sprintf("incorrect length of %s attribute: %d exceeds maximum %d",
  13. e.Type, e.Got, e.Max,
  14. )
  15. }
  16. // AttrLengthErr means that length for attribute is invalid.
  17. type AttrLengthErr struct {
  18. Attr AttrType
  19. Got int
  20. Expected int
  21. }
  22. func (e AttrLengthErr) Error() string {
  23. return fmt.Sprintf("incorrect length of %s attribute: got %d, expected %d",
  24. e.Attr,
  25. e.Got,
  26. e.Expected,
  27. )
  28. }