GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Feb 27, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed: Change in ConviseView $ErrorView MicrosoftDocs/PowerShell-Docs#7301
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
  • 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).
        • Issue filed:
      • Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        • Issue filed:
      • Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
        • Issue filed:
      • Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
        • Issue filed:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ghost ghost assigned Ilya (iSazonov) Feb 27, 2021
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from James Truher (JamesWTruher) and Paul Higinbotham (PaulHigin) February 27, 2021 02:35
@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Feb 27, 2021
iSazonov
Ilya (iSazonov) approved these changes Feb 27, 2021
View reviewed changes

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

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.

All reactions
Comment thread ...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@powercode

Staffan Gustafsson (powercode) commented Feb 27, 2021

Copy link
Copy Markdown
Collaborator

Can we have another view that maintains the current functionality?

It works well as it is now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Feb 28, 2021

Copy link
Copy Markdown
Member Author

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Feb 28, 2021

Copy link
Copy Markdown
Collaborator

Maybe it makes sense to add this in docs - $error vs ConciseView vs GetError.

SteveL-MSFT reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT Steve Lee (SteveL-MSFT) mentioned this pull request Feb 28, 2021
Change in ConviseView $ErrorView MicrosoftDocs/PowerShell-Docs#7301
Closed
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Mar 1, 2021

Copy link
Copy Markdown
Member Author

Static analysis failure is unrelated to this PR and being invested separately

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Mar 1, 2021
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov

Ilya (iSazonov) commented Mar 1, 2021

Copy link
Copy Markdown
Collaborator

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Steve Lee (SteveL-MSFT) and others added 2 commits March 5, 2021 13:52
@SteveL-MSFT
Update Concise ErrorView to not show line information for errors fr…
39c5363
…om script modules
@SteveL-MSFT @iSazonov
Update src/System.Management.Automation/FormatAndOutput/DefaultFormat…
5fbae4a
…ters/PowerShellCore_format_ps1xml.cs

Co-authored-by: Ilya <[email protected]>
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the module-error branch from 66949b1 to 5fbae4a Compare March 5, 2021 21:52
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Mar 5, 2021

Copy link
Copy Markdown
Member Author

Ilya (@iSazonov) are you ok to merge this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) closed this Mar 6, 2021
@iSazonov Ilya (iSazonov) reopened this Mar 6, 2021
@iSazonov

Ilya (iSazonov) commented Mar 6, 2021

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) "PowerShell-CI-static-analysis (Secret Scan)" blocks merging :-( Could you please ask anybody in your team to look the issue?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT Steve Lee (SteveL-MSFT) closed this Mar 8, 2021
@SteveL-MSFT Steve Lee (SteveL-MSFT) reopened this Mar 8, 2021
@iSazonov

Ilya (iSazonov) commented Mar 8, 2021

Copy link
Copy Markdown
Collaborator

The CI has the problem in all PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Ilya (iSazonov) merged commit 597bfc9 into PowerShell:master Mar 8, 2021
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.4 milestone Mar 8, 2021
@SydneyhSmith Sydney Smith (SydneyhSmith) mentioned this pull request Mar 8, 2021
-ErrorVariable parameter does not contain "inner" extension errors PowerShell/SecretManagement#102
Closed
@JustinGrote

Justin Grote (JustinGrote) commented Mar 8, 2021

Copy link
Copy Markdown
Contributor

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Mar 9, 2021

Copy link
Copy Markdown
Collaborator

Justin Grote (@JustinGrote) Could you please create a test for scenario you mean?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JustinGrote

Justin Grote (JustinGrote) commented Mar 10, 2021

Copy link
Copy Markdown
Contributor

Ilya (@iSazonov) sure, fairly simple:

mymodule.psm1

. .\myfunction.ps1

myfunction.ps1

function myfunction {
  throw 'This should not have a line indicator in conciseview'
}
iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Mar 11, 2021

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the module-error branch March 11, 2021 18:48
@JustinGrote

Justin Grote (JustinGrote) commented Mar 11, 2021

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT) How about if $myinv.MyCommand.Module.ModuleBase is present?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

Deleted user (ghost) commented Mar 16, 2021

Copy link
Copy Markdown

🎉v7.2.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

  • Release Notes
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT
Update Concise ErrorView to not show line information for errors fr…
12b4004
…om script module functions (PowerShell#14912)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov approved these changes
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
+1 more reviewer
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iSazonov Ilya (iSazonov)

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

7.2.0-preview.4

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@SteveL-MSFT @powercode @iSazonov @JustinGrote @PaulHigin
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.