Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,25 @@ def disassemble(self, threadId=None, frameIndex=None):

return disassembled_instructions, disassembled_instructions[memoryReference]

def _build_error_message(self, base_message, response):
"""Build a detailed error message from a DAP response.
Extracts error information from various possible locations in the response structure.
"""
error_msg = base_message
if response:
if "message" in response:
error_msg += " (%s)" % response["message"]
elif "body" in response and "error" in response["body"]:
if "format" in response["body"]["error"]:
error_msg += " (%s)" % response["body"]["error"]["format"]
else:
error_msg += " (error in body)"
else:
error_msg += " (no error details available)"
else:
error_msg += " (no response)"
return error_msg

def attach(
self,
*,
Expand Down Expand Up @@ -477,9 +496,8 @@ def cleanup():
if expectFailure:
return response
if not (response and response["success"]):
self.assertTrue(
response["success"], "attach failed (%s)" % (response["message"])
)
error_msg = self._build_error_message("attach failed", response)
self.assertTrue(response and response["success"], error_msg)

def launch(
self,
Expand Down Expand Up @@ -508,10 +526,8 @@ def cleanup():
if expectFailure:
return response
if not (response and response["success"]):
self.assertTrue(
response["success"],
"launch failed (%s)" % (response["body"]["error"]["format"]),
)
error_msg = self._build_error_message("launch failed", response)
self.assertTrue(response and response["success"], error_msg)

def build_and_launch(
self,
Expand Down
Loading