MCPcopy Create free account
hub / github.com/microsoft/debugpy / Response

Class Response

src/debugpy/common/messaging.py:839–952  ·  view source on GitHub ↗

Represents an incoming or an outgoing response to a Request. https://microsoft.github.io/debug-adapter-protocol/specification#response error_message corresponds to "message" in JSON, and is renamed for clarity. If success is False, body is None. Otherwise, it is a MessageDict associat

Source from the content-addressed store, hash-verified

837
838
839class Response(Message):
840 """Represents an incoming or an outgoing response to a Request.
841
842 https://microsoft.github.io/debug-adapter-protocol/specification#response
843
844 error_message corresponds to "message" in JSON, and is renamed for clarity.
845
846 If success is False, body is None. Otherwise, it is a MessageDict associated
847 with this Response, and so are all the nested dicts in it. If "body" was missing
848 or null in JSON, body is an empty dict.
849
850 If this is a response to an outgoing request, it will be handled by the handler
851 registered via self.request.on_response(), if any.
852
853 Regardless of whether there is such a handler, OutgoingRequest.wait_for_response()
854 can also be used to retrieve and handle the response. If there is a handler, it is
855 executed before wait_for_response() returns.
856
857 No further incoming messages are processed until the handler returns, except for
858 responses to requests that have wait_for_response() invoked on them.
859
860 To report failure to handle the event, the handler must raise an instance of
861 MessageHandlingError that applies_to() the Response object it was handling. Any
862 such failure is logged, after which the message loop moves on to the next message.
863
864 Helper methods Message.isnt_valid() and Message.cant_handle() can be used to raise
865 the appropriate exception type that applies_to() the Response object.
866 """
867
868 def __init__(self, channel, seq, request, body, json=None):
869 super().__init__(channel, seq, json)
870
871 self.request = request
872 """The request to which this is the response."""
873
874 if isinstance(body, MessageDict) and hasattr(body, "associate_with"):
875 body.associate_with(self)
876 self.body = body
877 """Body of the response if the request was successful, or an instance
878 of some class derived from Exception it it was not.
879
880 If a response was received from the other side, but request failed, it is an
881 instance of MessageHandlingError containing the received error message. If the
882 error message starts with InvalidMessageError.PREFIX, then it's an instance of
883 the InvalidMessageError specifically, and that prefix is stripped.
884
885 If no response was received from the other party before the channel closed,
886 it is an instance of NoMoreMessages.
887 """
888
889 def describe(self):
890 return f"#{self.seq} response to {self.request.describe()}"
891
892 @property
893 def payload(self):
894 return self.body
895
896 @property

Callers 2

respondMethod · 0.70
_parseMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…