Skip to content

ProtocolVersionError

Base classes

Name Children Inherits
RequestError
aclientp.exceptions
Raised when a JSON-RPC request fails.

⋔ Inheritance diagram

graph TD
  95970859091376["exceptions.ProtocolVersionError"]
  95970857446960["exceptions.RequestError"]
  125067848531296["builtins.Exception"]
  125067848532160["builtins.BaseException"]
  125067848591872["builtins.object"]
  95970857446960 --> 95970859091376
  125067848531296 --> 95970857446960
  125067848532160 --> 125067848531296
  125067848591872 --> 125067848532160

🛈 DocStrings

Bases: RequestError

The peer answered initialize with a protocol version this side does not speak.

Raised by clients before the rest of the response is validated, so an agent that only speaks another version (e.g. a v1 agent answering a v2 client) is reported as such instead of as a malformed response.

Source code in src/aclientp/exceptions.py
class ProtocolVersionError(RequestError):
    """The peer answered ``initialize`` with a protocol version this side does not speak.

    Raised by clients before the rest of the response is validated, so an agent that
    only speaks another version (e.g. a v1 agent answering a v2 client) is reported
    as such instead of as a malformed response.
    """

    def __init__(self, expected: int, received: Any, result: Any = None) -> None:
        super().__init__(-32600, "Invalid request", {"expected": expected, "received": received})
        self.expected = expected
        """The protocol version this side speaks."""
        self.received = received
        """The ``protocolVersion`` of the response (any JSON value, as sent by the peer)."""
        self.result = result
        """The raw ``initialize`` result, e.g. to show the peer's name."""

expected instance-attribute

expected = expected

The protocol version this side speaks.

received instance-attribute

received = received

The protocolVersion of the response (any JSON value, as sent by the peer).

result instance-attribute

result = result

The raw initialize result, e.g. to show the peer's name.

:fa-brands-github: Show source on GitHub