GeezerVison is showing github.com — Update `Concise` ErrorView to not show line information for errors from script module functions by SteveL-MSFT · Pull Request #14912 · PowerShell/PowerShell
Conversation
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 .psm1 file and to not show the script line information. Developers of modules can still use Get-Error to get that information during development time.
Before:
PS> install-module lskjfd
Install-Package: /Users/steve/.local/share/powershell/Modules/PowerShellGet/2.2.5/PSModule.psm1:9711
Line |
9711 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| No match was found for the specified search criteria and module name 'lskjfd'. Try Get-PSRepository to see all available registered module repositories.
After:
PS> install-module lskjfd
Install-Package: No match was found for the specified search criteria and module name 'lskjfd'. Try Get-PSRepository to see all available registered module repositories.
(Note that the error record here is coming from Install-Package being used by Install-Module which is what gets returned by PowerShell)
PR Context
This was reported by users.
PR Checklist
- PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- Summarized changes
- Make sure all
.h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
- This PR is ready to merge and is not Work in Progress.
- If the PR is work in progress, please add the prefix
WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
- Breaking changes
- User-facing changes
- Testing - New and feature
- Tooling
- I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
- OR
- I have considered the user experience from a tooling perspective and opened an issue in the relevant tool repository. This may include:
- Impact on PowerShell Editor Services which is used in the PowerShell extension for VSCode
(which runs in a different PS Host).
- Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
- Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
- Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor comment.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Can we have another view that maintains the current functionality?
It works well as it is now.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Staffan Gustafsson (@powercode) you can get the same (and more information) using Get-Error. It seems like a module should be an abstraction layer from the user. It could be configurable, but I also don't think we want tons of configuration that people don't use as I believe the current output of line information for a script module is really only useful to the author of the module.
|
powercode reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Maybe it makes sense to add this in docs - $error vs ConciseView vs GetError.
|
SteveL-MSFT reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Static analysis failure is unrelated to this PR and being invested separately
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Steve Lee (@SteveL-MSFT) "PowerShell-CI-static-analysis (Secret Scan)" blocks merging :-( Could you please ask anybody in your team to look the issue?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The CI has the problem in all PRs.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Steve Lee (@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 $myinvocation.mycommand.module.modulebase or something?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) sure, fairly simple:
mymodule.psm1
myfunction.ps1
function myfunction {
throw 'This should not have a line indicator in conciseview'
}
|
iSazonov reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Justin Grote (@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
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
🎉v7.2.0-preview.4 has been released which incorporates this pull request.:tada:
Handy links:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Labels
CL-General
Indicates that a PR should be marked as a general cmdlet change in the Change Log
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|