attributes_debug.go 722 B

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