errors.go 751 B

12345678910111213141516171819202122232425
  1. package mcp
  2. import "fmt"
  3. // UnsupportedProtocolVersionError is returned when the server responds with
  4. // a protocol version that the client doesn't support.
  5. type UnsupportedProtocolVersionError struct {
  6. Version string
  7. }
  8. func (e UnsupportedProtocolVersionError) Error() string {
  9. return fmt.Sprintf("unsupported protocol version: %q", e.Version)
  10. }
  11. // Is implements the errors.Is interface for better error handling
  12. func (e UnsupportedProtocolVersionError) Is(target error) bool {
  13. _, ok := target.(UnsupportedProtocolVersionError)
  14. return ok
  15. }
  16. // IsUnsupportedProtocolVersion checks if an error is an UnsupportedProtocolVersionError
  17. func IsUnsupportedProtocolVersion(err error) bool {
  18. _, ok := err.(UnsupportedProtocolVersionError)
  19. return ok
  20. }