Repository navigation
Print extension errors to the console - #86405
Konstantin Solomatov (solomatov) wants to merge 6 commits into
Conversation
|
So, the problem I am trying to solve with this, is visibility of extension errors. They are printed to some log file, but navigating there takes time, and there's no possibility of navigating with Cmd+Click to the source from there. |
|
See this: #86109 |
|
Will check in December. Have to figure out who is registering external errors. |
|
Benjamin Pasero (@bpasero) do you mean January? |
Benjamin Pasero (bpasero)
left a comment
There was a problem hiding this comment.
I do not feel like the "external error" part is something of my area, it is the first time I see it and it seems only to be used from many editor contributions that ask provider for results. Thus, assigning Johannes Rieken (@jrieken) and alexandrudima to decide if this is correct thing to do.
However, as for where to hook this into the workbench, it should be here:
|
"External error" are those that are caused by extensions and because we don't want them in our error telemetry we have special handling for them. That's the fragment I know of this and the important part to keep in mind when looking at the errors-util - of which I am not very knowledgeable. |
Alexandru Dima (alexdima)
left a comment
There was a problem hiding this comment.
LGTM. I would log even VS Code internal errors to console.log... I am not sure why we are so picky today and log errors only to the logfile.
|
alexandrudima but we do, no? That is what: essentially does. |
|
Benjamin Pasero (@bpasero) I looked at vscode/src/vs/workbench/browser/workbench.ts Lines 109 to 125 in d386b49 AFAICT, this PR adds that errors that occur in extension are additionally being logged to the console. My review was that I would print all errors to the console, internal ones and extension ones. |
|
alexandrudima my understanding is that we always have a console logger running that puts everything to console as well: vscode/src/vs/platform/log/common/log.ts Line 161 in d386b49 Here is an error I logged via log service: Maybe Sandeep Somavarapu (@sandy081) could chime in on that. If this is true, the PR becomes easier, because the same method can be used basically for internal and external errors. |
|
Benjamin Pasero (@bpasero) alexandrudima Johannes Rieken (@jrieken) So is there anything I can do with PR? |
|
Benjamin Pasero (@bpasero) Done. Made the PR much simpler :-) |
|
Konstantin Solomatov (@solomatov) I am not sure this resolves the issue of reporting external errors, or does it? I think your other changes for allowing to listen on external errors is still needed, no? As for printing errors to the console, this should happen automatically when using the log service as I outlined before. |
|
Benjamin Pasero (@bpasero) It doesn't happen automatically. It's being prints only to the log which is available in the debugged copy of vscode. |
|
Benjamin Pasero (@bpasero) So ok. We write the fact that the error message happened. But, we don't write a stacktrace. I think it's better to write it in a way which will print exception there and remove my change. |
|
Yeah but then I would say that we should do that at the place where we log to the console, no? That way everyone benefits. Let's wait for Sandeep Somavarapu (@sandy081) to chime in. To summarize: every error that gets logged to the logger should be printed to the dev tools with a stack (if its an error). |
|
Benjamin Pasero (@bpasero) It was printed but in a not very helpful way. See my last commit. It became even better :-) |
|
I think, it was a bug. We didn't consider Errors without a message or with an empty or undefined messages as real errors. |
|
Benjamin Pasero (@bpasero) So, the problem was, I put a number of exceptions without error message, created like this: throw new Error(). These errors didn't print out because they didn't have message. My last commit fixes this problem. Such errors are now printed like everything else. |
|
Konstantin Solomatov (@solomatov) ah nice, I like where this is going. However, one suggestion: if |
|
Benjamin Pasero (@bpasero) I debugged it. Actually, it's defined and it's an empty string but due to how conditions works in js, it has funny behavior. Added your suggestions. |
|
Yes, we log all messages to both log file and console. Konstantin Solomatov (@solomatov)
Yes, Console logger is not handling errors correctly thereby not printing stack traces whereas file logger (spdlog) does it correctly. Feel free to fix the console logger vscode/src/vs/platform/log/common/log.ts Lines 194 to 204 in 2bb6cfc You can refer to code how we do it already in spdlogger vscode/src/vs/platform/log/node/spdlogService.ts Lines 113 to 124 in 2bb6cfc |
|
Sandeep Somavarapu (@sandy081) So, do you want me to use the same code for printing exception? Or is my way is ok? (I think they are more or less equivalent.) |
|
I would prefer the existing way as it was there already (which is in spdlog). |
|
Sandeep Somavarapu (@sandy081) I checked it, and Error isn't passed there. Just a string sent there. |
|
Benjamin Pasero (@bpasero) Sandeep Somavarapu (@sandy081) Created #86617 to make the change. Closing this PR. |

Johannes Rieken (@jrieken) That's another attempt to improve diagnostics.