Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: don't show "Unable to eval expression" error message already under WATCH #143

Closed
ramya-rao-a opened this issue Jun 1, 2020 · 4 comments
Assignees
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge

Comments

@ramya-rao-a
Copy link
Contributor

From microsoft/vscode-go#3227 by @kzhui125

1

In other extensions such as python, if you eval an expression which produces error, the error is only shown in "WATCH".

But in VSCode go extension, the message box is shown, which is not needed.

And the message box pop up again and again, which has very bad experience.

There are cases when you put a variable in watch, but not available in current debug point.

@ramya-rao-a
Copy link
Contributor Author

I don't see how we can communicate the error to VS Code if we don't send the error response as shown in https://github.com/microsoft/vscode-go/blob/12fd44a26788fb285207a3482dbb21d486b9d8b9/src/debugAdapter/goDebug.ts#L1332

If we remove that, then the watch pane would simply say "not available".
But another place to evaluate symbols is the debug console which would not say anything if we don't send an error response.

@ramya-rao-a
Copy link
Contributor Author

From microsoft/vscode-go#3227 (comment) by @hyangah:

My proposal is not to drop the error response, but to find another way (is it possible to formulate it as a regular response, but with some indication on error?). Does anyone know how python extension handles this?

@stamblerre stamblerre changed the title Don't show "Unable to eval expression" message box debug: don't show "Unable to eval expression" error message Jun 3, 2020
@stamblerre stamblerre added the Debug Issues related to the debugging functionality of the extension. label Jun 3, 2020
@polinasok
Copy link
Contributor

My first thought was the same as @hyangah's: instead of sending ErrorResponse, send back successful EvaluateResponse, setting the result of the expression to the error message. Quick test of this alternative code snippet (which could be used in case of args.context=='watch')

response.body = {result: err.toString(), variablesReference: 0};
this.sendResponse(response);

yielded expected results: the error appeared in the Watch section without the pop-up.

Request:

{"command":"evaluate","arguments":{"expression":"bbbb==1","frameId":1000,"context":"watch"},"type":"request","seq":9}

Response before:

{"seq":0,"type":"response","request_seq":9,"command":"evaluate","success":false,"message":"Unable to eval expression: \"{e}\"","body":{"error":{"id":2009,"format":"Unable to eval expression: \"{e}\"","variables":{"e":"could not find symbol value for bbbb"},"showUser":true}}}

Response after:

{"seq":0,"type":"response","request_seq":9,"command":"evaluate","success":true,"body":{"result":"could not find symbol value for bbbb","variablesReference":0}}

But this seems like the wrong way to go, given the spec.

@polinasok
Copy link
Contributor

Now lets look into what vscode-python does, given that it has the desired behavior without the pop-up. Its debug adaptor appears to forward things over to PTVSD, which also uses DAP. And PTVSD sends back neither a successful EvaluateResponse nor a full-fledged ErrorResponse, but something in-between - an EvaluateResponse with the body set to EvaluteResponseBody and not ErrorResponseBody while success and message fields are set as they would be in an ErrorResponse.

Turning on logging with "logToFile": true in launch.json, I get logging from the newly released debugpy, which is consistent with the same approach:

Server[1] --> {
                 "pydevd_cmd_id": 502, 
                 "seq": 40, 
                 "type": "response", 
                 "request_seq": 15, 
                 "success": false, 
                 "command": "evaluate", 
                 "message": "NameError: name 'abcdef' is not defined", 
                 "body": {
                     "variablesReference": 0, 
                     "presentationHint": {}, 
                     "result": "NameError: name 'abcdef' is not defined"
                 }
             }

This is then forwarded up the adaptor chain, stripping the EvaluateResponseBody and turning this into a proper ErrorResponse (since success==false):

Client <-- Adapter:
{
    "seq": 19,
    "type": "response",
    "request_seq": 11,
    "success": false,
    "command": "evaluate",
    "message": "NameError: name 'abcdef' is not defined"
}

But the big difference with Go is that the optional error Message in the body is not set at all.
Upon further inspection, I noticed that the body has a field showUser, which is set to true in the vscode-go response. I think that's the key here and we just need to set it to false in case of 'watch' context.

I will put together a quick PR tomorrow.

@polinasok polinasok self-assigned this Jun 3, 2020
@polinasok polinasok changed the title debug: don't show "Unable to eval expression" error message debug: don't show "Unable to eval expression" error message already under WATCH Jun 9, 2020
@golang golang locked and limited conversation to collaborators Jun 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants