Repository navigation
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.
Description
#10641 - The new error formatting is nice but it might have some disadvantages, too.
Demo script
function Test-Error {
Write-Error @'
Oops, error! Details:
- Somewhat long details line 1, and more somewhat long details line 1.
- Somewhat long details line 2, and more somewhat long details line 2.
'@
}
Test-ErrorNormalView error formatting (good old but with some "noise"):
Test-Error : Oops, error! Details:
- Somewhat long details line 1, and more somewhat long details line 1.
- Somewhat long details line 2, and more somewhat long details line 2.
At C:\ROM\z\_191023_233922_ps_ErrorView\bad-error.ps1:11 char:1
+ Test-Error
+ ~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Test-Error
ConciseView error formatting (nice and shiny but with issues):
Test-Error: C:\ROM\z\_191023_233922_ps_ErrorView\bad-error.ps1
Line |
11 | Test-Error
| ^ Oops, error! Details: - Somewhat long details line 1, and more somewhat long details line 1. - Somewhat long details line 2, and more somewhat long
| details line 2.
Some issues
- The file path and line number are in different places. Even for a human it requires
some effort to connect them together in order to go to the problem location.
But it is also the challenge for various error parsers in text editors, log
parsers, etc. VSCode, for example, understands "standard link" patterns as
<path>(<line>),<path>:<line> [char:<column>]. Is it going to work well
with the new ConciseView formatting? - Column number is missing. The caret position is shown in a different way,
this is somewhat fine for humans but programs (VSCode and others) will
have difficulties with getting this info. - Line formatting of error messages is not respected. Yes, in most cases error
messages are one liners. But lengthy errors with some detailed multiline
descriptions are not rare, too. Preserving the original formatting of such
messages would be useful, they were composed in such a way for reasons. - When the error caret position is more to the right, the error message first
line is more indented and gets even more difficult to read for long messages.
Copying the error messages is also difficult with such extra indentation.
Suggestion
For ConciseView, why not just strip some "noise", i.e. CategoryInfo and
FullyQualifiedErrorId lines and keep the rest just like in NormalView?
Example:
Test-Error : Oops, error! Details:
- Somewhat long details line 1, and more somewhat long details line 1.
- Somewhat long details line 2, and more somewhat long details line 2.
At C:\ROM\z\_191023_233922_ps_ErrorView\bad-error.ps1:11 char:1
+ Test-Error
+ ~~~~~~~~~~
All the above issues are resolved (or at least negative effects reduced).
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.
Activity
theJasonHelmick commentedon Oct 28, 2019
Thank you for the feedback! In regards to line and column - the positional information is still contained in the error object itself so non-humans should still be able to read that. You should notice it if you use the new cmdlet Get-Error or with $error[0].
nightroman commentedon Oct 28, 2019
I believe in many scenarios tools and apps like VSCode just parse the output text, not the actual error instances. To rephrase, did you or somebody else tried this update in VSCode? If a new format error is written to the output, can you click there in order to jump to the source file error line and column?
morsley commentedon Dec 17, 2019
Roman Kuzmin 1967-2026 (@nightroman) If you're referring to the vscode extension, they use powershell's shell as a server to process commands so the error object is still intact. Next month, they'll be moving to a omnisharp-based server with PS7 GA which should address performance issues seen there.
nightroman commentedon Dec 17, 2019
@TheIncorrigible1 This is good. And yet, have you tried, does it work well? I have not, I just think it might not work.
In other words, can you click in the output where the error is just printed so that VSCode jumps to the source code where the error is?
SteveL-MSFT commentedon Dec 17, 2019
Roman Kuzmin 1967-2026 (@nightroman) there's an existing issue to debate what to do with long error messages: #10760
For VSCode where the terminal supports linking to the location, the NormalView format doesn't work completely.
file:lineis understood by the VSCode terminal, but notfile:line char:num. Looking at the output of dotnetcli, this format works:file(line,char)but is less obvious to a person what it means, but does link correctly. Here's an example:nightroman commentedon Dec 18, 2019
For VSCode the NormalView format works at least partially (file:line), right out of the box. And it may perhaps fine tuned via VSCode settings (some one-liner regex pattern?).
As for the ConciseView, in its current form, VSCode probably does not work at all. And it is very tricky to tune it even using settings (multi-line regex patterns? is it even supported?).
Also, it's not just about VSCode. There are other editors, IDEs (I am working on one of them), log file processing apps, etc. Ideally, errors should contain at least
<file>and<line>at the same line, in one of "well known" formats. Of course<column>is useful, too. The ConciseView does not fit at all.SteveL-MSFT commentedon Dec 18, 2019
Adding the line as in
file:lineis simple and, I believe, doesn't make the text less human-readable. I was simply asserting that trying to add the column with parenthesis syntax will probably make it confusing to most users.nightroman commentedon Dec 18, 2019
Steve Lee (@SteveL-MSFT) I believe (and have tried), VSCode understands
file:line:column, too. Will it be confusing if supported?But if at least the line is added, it's already much better usability.
nightroman commentedon Dec 18, 2019
I think this would be ideal for ConciseView but it's just me :)
It is less shiny perhaps and less "innovative" but it is concise and practical, see my arguments in the first post.
SteveL-MSFT commentedon Dec 18, 2019
file:line:column does work, but I don't think it's easily understandable by users and most users will see the error in a terminal they can't click. However, one option (and I don't like to hardcode for a specific term) is to detect we are using vscode and emit the column information since we know it's clickable.
Note that you can always implement a new errorview and if the community likes it we can include it with PS7.x.
nightroman commentedon Dec 18, 2019
Steve Lee (@SteveL-MSFT) Thank you for listening and taking actions.