Add messages to error responses (#838)

* Add error messages for to error responses.

* Update tests

* Update some failure message text.

* update test_unknown_thread test
This commit is contained in:
Karthik Nadig 2018-09-27 11:06:58 -07:00 committed by GitHub
parent b47df51478
commit 173600754a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 15 deletions

View file

@ -1529,7 +1529,7 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
xml = self.parse_xml_response(resp_args)
except SAXParseException as ex:
self.send_error_response(request)
self.send_error_response(request, resp_args)
return
try:
@ -1611,8 +1611,10 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
pyd_tid = self.thread_map.to_pydevd(vsc_tid)
except KeyError:
# Unknown thread, nothing much we cna do about it here
self.send_error_response(request)
# Unknown thread, nothing much we can do about it here
self.send_error_response(
request,
'Thread {} not found'.format(vsc_tid))
return
try:
@ -1722,7 +1724,9 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
pyd_var = self.var_map.to_pydevd(vsc_var)
except KeyError:
self.send_error_response(request)
self.send_error_response(
request,
'Variable {} not found in frame'.format(vsc_var))
return
if len(pyd_var) == 3:
@ -1737,7 +1741,7 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
xml = self.parse_xml_response(resp_args)
except SAXParseException as ex:
self.send_error_response(request)
self.send_error_response(request, resp_args)
return
try:
@ -1835,13 +1839,15 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
if var_name.startswith('(return) '):
self.send_error_response(
request,
'Cannot change return value.')
'Cannot change return value')
return
try:
pyd_var = self.var_map.to_pydevd(vsc_var)
except KeyError:
self.send_error_response(request)
self.send_error_response(
request,
'Variable {} not found in frame'.format(vsc_var))
return
lhs_expr = self._get_variable_evaluate_name(pyd_var, var_name)
@ -1877,7 +1883,7 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
xml = self.parse_xml_response(resp_args)
except SAXParseException as ex:
self.send_error_response(request)
self.send_error_response(request, resp_args)
return
try:
@ -1916,7 +1922,7 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
xml = self.parse_xml_response(resp_args)
except SAXParseException as ex:
self.send_error_response(request)
self.send_error_response(request, resp_args)
return
try:
@ -2262,7 +2268,9 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor):
try:
pyd_tid, pyd_fid = self.frame_map.to_pydevd(vsc_fid)
except KeyError:
self.send_error_response(request)
self.send_error_response(
request,
'Frame {} not found'.format(vsc_fid))
cmd_args = '{}\t{}\t{}\t{}'.format(pyd_tid, pyd_fid, 'LOCAL', text)
_, _, resp_args = yield self.pydevd_request(

View file

@ -393,12 +393,14 @@ class StackTraceTests(NormalRequestTest, unittest.TestCase):
with self.launched():
with self.hidden():
tid, _ = self.set_thread('x')
req = self.send_request(
threadId=tid + 1,
self.send_request(
threadId=12345,
)
received = self.vsc.received
self.assert_vsc_failure(received, [], req)
self.assert_vsc_received(received, [
self.expected_failure('Thread 12345 not found'),
])
self.assert_received(self.debugger, [])
@ -528,7 +530,7 @@ class VariablesTests(NormalRequestTest, unittest.TestCase):
received = self.vsc.received
self.assert_vsc_received(received, [
self.expected_failure(''),
self.expected_failure('Variable 12345 not found in frame'),
# no events
])
@ -670,7 +672,7 @@ class SetVariableTests(NormalRequestTest, unittest.TestCase):
received = self.vsc.received
self.assert_vsc_received(received, [
self.expected_failure(''),
self.expected_failure('Variable 12345 not found in frame'),
# no events
])