AREPL-vscode icon indicating copy to clipboard operation
AREPL-vscode copied to clipboard

Links from AREPL error output back to code

Open LightCC opened this issue 6 years ago • 6 comments

Enhancement/Suggestion:

When the code being run by AREPL throws, the Traceback is printed, but it is plain text.

Can AREPL convert the files and line numbers to a link, that will open to that particular line or the following text?

I've actually clicked the static text multiple times expecting this... Or clicked the actual link to the Google search that AREPL does add in, thinking I'd go to that spot in the code.

Not sure what other IDE I used that I am expecting that behavior, but I believe it would be a big help. Thanks! Great extension.

Example

Each of the following Red/Orange/Brownish files+line numbers in this traceback could be a link that goes to that spot in an existing open editor, or opens up a new editor with that file, at that location.

image

LightCC avatar Sep 17 '19 16:09 LightCC

I tried to do this before and for some reason it didn't work. I'll take a second look at this.

Almenon avatar Sep 17 '19 20:09 Almenon

saving some links for myself:

https://code.visualstudio.com/api/extension-guides/webview https://code.visualstudio.com/api/references/vscode-api https://code.visualstudio.com/api/references/commands https://github.com/microsoft/vscode-docs/blob/master/api/extension-guides/command.md

Almenon avatar Sep 19 '19 22:09 Almenon

note to myself: this would be easier if python outputted errors as properly strucutred json instead of string or if i refactored webview.....

Almenon avatar Sep 19 '19 22:09 Almenon

some progress on this: I just switched to sending structured exception information in the backend. This might make it easier to do this in the frontend.

https://github.com/Almenon/AREPL-backend/pull/98

Almenon avatar Sep 28 '19 19:09 Almenon

So the traceback contains a __cause__ or __context__ field (see https://stackoverflow.com/questions/11235932/what-is-the-difference-between-cause-and-context) that you could follow to get the original exception. Unfortunately jsonpickle doesn't pickle it.

I could:

A) use https://github.com/ionelmc/python-tblib B) Serialize it myself - iterate through __cause__/__context__ untill I reach the end and add them as properties to the exception.

Almenon avatar Nov 09 '19 19:11 Almenon

I chose option B - the backend sends the error over properly now, so now I need to write code to handle it in the frontend.

Almenon avatar Nov 24 '19 16:11 Almenon