question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get-Culture's errors with -ErrorAction are not terminating errors

See original GitHub issue

Prerequisites

Steps to reproduce

Cause an error in Get-Culture while using -ErrorAction Stop . It does not terminate.

Expected behavior

console Terminating errors should cause the function to end. For example Get-Item -Ea Stop

function funcShouldStop2 {
    # expects terminating error
    [CmdletBinding()]
    param()
    Get-Item 'somefakefilename' -ea Stop
    '⚠ Should Never Reach'
}
funcShouldStop2

No output

Actual behavior

function funcShouldStop1 {
    # expects terminating error
    [CmdletBinding()]
    param()
    Get-Culture 'en-uk' -ea Stop
    '⚠ Should Never Reach'
}
> funcShouldStop1

Get-Culture: 
Line |
   5 |      Get-Culture 'en-uk' -ea Stop
     |                  ~~~~~~~
     | Cannot validate argument on parameter 'Name'. The argument "en-uk" does not belong to the set ",aa,aa-DJ,aa-ER,aa-ET....snip....ns-MO,zh-SG,zh-Hant,zh-HK,zh-MO,zh-TW,zu,zu-ZA" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
⚠ Should Never Reach

Note that it does reach ⚠ Should Never Reach

Error details

> get-Error

Cannot validate argument on parameter 'Name'. The argument "en-uk" does not belong to the set ",aa,aa-DJ,aa-ER,aa-ET,af,af-NA,af-ZA,agq,agq-CM,ak,ak-GH,am,am-ET,ar,ar-001,ar-AE,ar-BH,ar-DJ,ar-DZ,ar-EG,ar-ER,ar-IL,ar-IQ,ar-JO,ar-KM,ar-KW,ar-LB,ar-LY,ar-MA,ar-MR,ar-OM,ar-PS,ar-QA,ar-SA,ar-SD,ar-SO,ar-SS,ar-SY,ar-TD,ar-TN,ar-YE,arn,arn-CL,as,as-IN,asa,asa-TZ,ast,ast-ES,az,az-Cyrl,az-Cyrl-AZ,az-Latn,az-Latn-AZ,ba,ba-RU,bas,bas-CM,be,be-BY,bem,bem-ZM,bez,bez-TZ,bg,bg-BG,bm,bm-Latn-ML,bn,bn-BD,bn-IN,bo,bo-CN,bo-IN,br,br-FR,brx,brx-IN,bs,bs-Cyrl,bs-Cyrl-BA,bs-Latn,bs-Latn-BA,byn,byn-ER,ca,ca-AD,ca-ES,ca-ES-valencia,ca-FR,ca-IT,ccp,ccp-Cakm-BD,ccp-Cakm-IN,ce,ce-RU,ceb,ceb-Latn-PH,cgg,cgg-UG,chr,chr-Cher-US,ku,ku-Arab-IQ,ku-Arab-IR,co,co-FR,cs,cs-CZ,cu,cu-RU,cy,cy-GB,da,da-DK,da-GL,dav,dav-KE,de,de-AT,de-BE,de-CH,de-DE,de-IT,de-LI,de-LU,dje,dje-NE,dsb,dsb-DE,dua,dua-CM,dv,dv-MV,dyo,dyo-SN,dz,dz-BT,ebu,ebu-KE,ee,ee-GH,ee-TG,el,el-CY,el-GR,en,en-001,en-150,en-AE,en-AG,en-AI,en-AS,en-AT,en-AU,en-BB,en-BE,en-BI,en-BM,en-BS,en-BW,en-BZ,en-CA,en-CC,en-CH,en-CK,en-CM,en-CX,en-CY,en-DE,en-DK,en-DM,en-ER,en-FI,en-FJ,en-FK,en-FM,en-GB,en-GD,en-GG,en-GH,en-GI,en-GM,en-GU,en-GY,en-HK,en-IE,en-IL,en-IM,en-IN,en-IO,en-JE,en-JM,en-KE,en-KI,en-KN,en-KY,en-LC,en-LR,en-LS,en-MG,en-MH,en-MO,en-MP,en-MS,en-MT,en-MU,en-MW,en-MY,en-NA,en-NF,en-NG,en-NL,en-NR,en-NU,en-NZ,en-PG,en-PH,en-PK,en-PN,en-PR,en-PW,en-RW,en-SB,en-SC,en-SD,en-SE,en-SG,en-SH,en-SI,en-SL,en-SS,en-SX,en-SZ,en-TC,en-TK,en-TO,en-TT,en-TV,en-TZ,en-UG,en-UM,en-US,en-US-posix,en-VC,en-VG,en-VI,en-VU,en-WS,en-ZA,en-ZM,en-ZW,eo,eo-001,es,es-419,es-AR,es-BO,es-BR,es-BZ,es-CL,es-C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se-NO,se-SE,seh,seh-MZ,ses,ses-ML,sg,sg-CF,shi,shi-Latn,shi-Latn-MA,shi-Tfng,shi-Tfng-MA,si,si-LK,sk,sk-SK,sl,sl-SI,sma,sma-NO,sma-SE,smj,smj-NO,smj-SE,smn,smn-FI,sms,sms-FI,sn,sn-Latn-ZW,so,so-DJ,so-ET,so-KE,so-SO,sq,sq-AL,sq-MK,sq-XK,sr,sr-Cyrl,sr-Cyrl-BA,sr-Cyrl-ME,sr-Cyrl-RS,sr-Cyrl-XK,sr-Latn,sr-Latn-BA,sr-Latn-ME,sr-Latn-RS,sr-Latn-XK,ss,ss-SZ,ss-ZA,ssy,ssy-ER,st,st-LS,st-ZA,sv,sv-AX,sv-FI,sv-SE,sw,sw-CD,sw-KE,sw-TZ,sw-UG,syr,syr-SY,ta,ta-IN,ta-LK,ta-MY,ta-SG,te,te-IN,teo,teo-KE,teo-UG,tg,tg-Cyrl-TJ,th,th-TH,ti,ti-ER,ti-ET,tig,tig-ER,tk,tk-TM,tn,tn-BW,tn-ZA,to,to-TO,tr,tr-CY,tr-TR,ts,ts-ZA,tt,tt-RU,twq,twq-NE,tzm,tzm-Latn-MA,ug,ug-CN,uk,uk-UA,ur,ur-IN,ur-PK,uz,uz-Arab,uz-Arab-AF,uz-Cyrl,uz-Cyrl-UZ,uz-Latn,uz-Latn-UZ,vai,vai-Latn,vai-Latn-LR,vai-Vaii,vai-Vaii-LR,ve,ve-ZA,vi,vi-VN,vo,vo-001,vun,vun-TZ,wae,wae-CH,wal,wal-ET,wo,wo-SN,xh,xh-ZA,xog,xog-UG,yav,yav-CM,yi,yi-001,yo,yo-BJ,yo-NG,zgh,zgh-Tfng-MA,zh,zh-Hans,zh-CN,zh-Hans-HK,zh-Hans-MO,zh-SG,zh-Hant,zh-HK,zh-MO,zh-TW,zu,zu-ZA" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.

Environment data

I get the same results using Pwsh -NoP

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image And the end image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SeeminglySciencecommented, Nov 12, 2021

In that case, shouldn’t this halt?

Note the wording there, it’s pipeline terminating, which works differently than call stack terminating errors. throw and -ea stop are the latter, parameter validation and PSCmdlet.ThrowTerminatingError are the former.

Note I’m not defending this behavior, but it is by design.

0reactions
msftbot[bot]commented, Dec 11, 2021

This issue has been marked as by-design and has not had any activity for 1 day. It has been closed for housekeeping purposes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Non-Terminating Errors in PowerShell
Summary: Ed Wilson, Microsoft Scripting Guy, talks about understanding non-terminating errors in Windows PowerShell. Hey, Scripting Guy!
Read more >
PowerShell: Catch errors but continue without loop?
1 Answer. The errors you're describing are non-terminating errors, which you can collect in a variable with the common -ErrorVariable parameter ...
Read more >
Why do commands in Try/Catch sometimes need
A terminating error is an error that halts the execution of a cmdlet, script or program. This will be caught by Try {}...
Read more >
Can someone please explain this seemingly inconsistent ...
The error is not caught because try / catch only handles terminating errors, and Get-Item is throwing a non-terminating error. So the error...
Read more >
[SOLVED] terminating vs non-terminating errors - PowerShell
A Non- Terminating error is one that does not prevent the command from moving on and trying the next item on a list...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found