attributes_debug.go 603 B

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