Update Concise ErrorView to not show line information for errors from script module functions#14912
Conversation
iSazonov
left a comment
There was a problem hiding this comment.
LGTM with one minor comment.
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
|
Can we have another view that maintains the current functionality? It works well as it is now. |
|
@powercode you can get the same (and more information) using |
|
Maybe it makes sense to add this in docs - $error vs ConciseView vs GetError. |
|
Static analysis failure is unrelated to this PR and being invested separately |
We could only run markdown tests (1) if CL-Doc label is present and (2) in nightly build. |
…om script modules
…ters/PowerShellCore_format_ps1xml.cs Co-authored-by: Ilya <darpa@yandex.ru>
66949b1 to
5fbae4a
Compare
|
@iSazonov are you ok to merge this? |
|
@SteveL-MSFT "PowerShell-CI-static-analysis (Secret Scan)" blocks merging :-( Could you please ask anybody in your team to look the issue? |
|
The CI has the problem in all PRs. |
|
@iSazonov @SteveL-MSFT haven't had a chance to test but will this work for powershell modules that aren't a single .psm1 file? It's common for modules to be broken into "Private","Public", etc. folders and dot source in the files from there. Maybe better to test for |
|
@JustinGrote Could you please create a test for scenario you mean? |
|
@iSazonov sure, fairly simple: mymodule.psm1 . .\myfunction.ps1myfunction.ps1 function myfunction {
throw 'This should not have a line indicator in conciseview'
} |
|
@JustinGrote that still shows line information as the ErrorRecord shows the ps1 as the source and I don't see a way to map it to the psm1 |
|
@SteveL-MSFT How about if |
|
🎉 Handy links: |
PR Summary
Currently, if a script module (like PowerShellGet v2) has an error, it shows internal information to the user which can be confusing. Change is to check if the invocation is from a
.psm1file and to not show the script line information. Developers of modules can still useGet-Errorto get that information during development time.Before:
After:
(Note that the error record here is coming from
Install-Packagebeing used byInstall-Modulewhich is what gets returned by PowerShell)PR Context
This was reported by users.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.ConviseView$ErrorView MicrosoftDocs/PowerShell-Docs#7301(which runs in a different PS Host).