Skip to content

Add about_Error_Handling and fix error terminology across docs#12890

Merged
sdwheeler merged 10 commits intoMicrosoftDocs:mainfrom
SufficientDaikon:docs/error-handling-overhaul
Apr 2, 2026
Merged

Add about_Error_Handling and fix error terminology across docs#12890
sdwheeler merged 10 commits intoMicrosoftDocs:mainfrom
SufficientDaikon:docs/error-handling-overhaul

Conversation

@SufficientDaikon
Copy link
Copy Markdown
Contributor

@SufficientDaikon SufficientDaikon commented Mar 26, 2026

scope impact age type

Creates a comprehensive about_Error_Handling reference topic and corrects factual errors across eight existing files. Every correction is cited against the PowerShell engine source code.


Btw, this entire PR is generated by opus, so do keep that in mind as you read through

At a glance

flowchart TD
    A["Error occurs"] --> B{"Error type?"}
    B -->|"WriteError()"| C["Non-terminating"]
    B -->|"ThrowTerminatingError()"| D["Statement-terminating"]
    B -->|"throw keyword"| E["Script-terminating"]
    C --> F["Pipeline continues"]
    D --> G["Statement stops, script continues"]
    E --> H["Call stack unwinds"]
    style C fill:#E7E6E6,color:#333
    style D fill:#FFF2CC,color:#333
    style E fill:#F8D7DA,color:#333
    style F fill:#E2EFDA,color:#333
    style G fill:#FFF2CC,color:#333
    style H fill:#F8D7DA,color:#333
Loading

The existing docs use "terminating error" as one category. The engine has three. This PR fixes that — and several other inaccuracies discovered along the way.


What this PR corrects

Warning

These are factual corrections, not style changes. Each one fixes a claim that contradicts the engine's actual behavior.

1. "ErrorAction has no effect on terminating errors"

ClaimRealitySource
about_CommonParameters and about_Preference_Variables said -ErrorAction / $ErrorActionPreference have "no effect on terminating errors" -ErrorAction Stop escalates non-terminating errors to terminating errors by generating an ActionPreferenceStopException [SRC-1] _WriteErrorSkipAllowCheck

2. "throw always generates a script-terminating error"

ClaimRealitySource
about_Throw described throw as unconditionally script-terminating $ErrorActionPreference = 'SilentlyContinue' or 'Ignore' can suppress throw — execution continues at the next statement [SRC-2] CheckActionPreference intercepts before rethrow

3. "Ignore prevents $Error recording"

ClaimRealitySource
about_Preference_Variables, about_CommonParameters, and about_Automatic_Variables implied Ignore universally prevents $Error recording Ignore only prevents $Error recording for non-terminating errors. Terminating errors (including suppressed throw) still record in $Error [SRC-1] AppendDollarError skip is in non-terminating path only

4. -ErrorAction Stop escalation type

ClaimRealitySource
Multiple files described -ErrorAction Stop as producing one specific error type It's context-dependent: script-terminating in non-advanced contexts, statement-terminating in advanced functions ([CmdletBinding()]) [SRC-1] + [SRC-3] SuppressPromptInInterpreter flag

5. Code bug in about_Try_Catch_Finally

- if (Test-Path $tempPath) { Remove-Item $tempFile }
+ if (Test-Path $tempFile) { Remove-Item $tempFile }

$tempPath was never defined — the variable is $tempFile (line 261).


What this PR adds

New topic: about_Error_Handling

A ~500-line reference that didn't exist before. Covers:

Section What it explains
Error categories Non-terminating, statement-terminating, script-terminating — what generates each, how each propagates
Error state variables $?, $Error, $LASTEXITCODE — when each updates and when it doesn't
-ErrorAction values What each value does, with a table showing behavior per error type
Escalation mechanics How Stop turns non-terminating into terminating, and why it differs in advanced vs non-advanced contexts
$ErrorActionPreference asymmetry Why the preference variable affects both non-terminating and statement-terminating errors, but -ErrorAction only affects non-terminating [SRC-1] [SRC-3]
throw suppression How $ErrorActionPreference can suppress throw, and the Ignore/$Error caveat [SRC-2]
try/catch/trap How each mechanism catches errors, including the PropagateExceptionsToEnclosingStatementBlock flag [SRC-4]
Best practices Guidance on Write-Error vs ThrowTerminatingError() vs throw in functions

Files changed

# File What changed
1 about_Error_Handling.md New — comprehensive error handling reference
2 about_CommonParameters.md Remove false "no effect" claim; qualify Ignore/$Error; explain Stop escalation
3 about_Preference_Variables.md Same $ErrorActionPreference fix; correct Ignore description
4 about_Throw.md Add suppression caveat and Ignore/$Error NOTE
5 about_Try_Catch_Finally.md Add error category distinction; suppression NOTE; fix $tempPath bug
6 about_Trap.md Update error type descriptions in YAML and intro
7 about_Automatic_Variables.md Qualify $Error/Ignore as non-terminating only
8 About.md Add about_Error_Handling to topic index; update 3 descriptions
9 everything-about-exceptions.md Fix -ErrorAction Stop terminology to "terminating" (context-dependent)

Source citations

Every factual claim links back to engine source. Here's the index:

Tag File What it proves
[SRC-1] MshCommandRuntime.cs WriteError() checks -ErrorAction; Stop creates ActionPreferenceStopException; ThrowTerminatingError() does NOT check -ErrorAction (except Break)
[SRC-2] MiscOps.cs L1744-1782 CheckActionPreference can suppress throw when $ErrorActionPreference = SilentlyContinue/Ignore
[SRC-3] MiscOps.cs L1564-1631 FindMatchingHandler unwraps ActionPreferenceStopException; SuppressPromptInInterpreter controls escalation type
[SRC-4] Compiler.cs L5244-5260 PropagateExceptionsToEnclosingStatementBlock = true inside try blocks
Terminology precedent already in this repo

The terms "statement-terminating" and "script-terminating" already exist in reference/7.6/:

  • about_Calculated_Properties.md (line 504): "statement-terminating and script-terminating errors"
  • about_Pipeline_Chain_Operators.md (lines 122, 205): "script-terminating error"
  • about_Pwsh.md (lines 117, 201): "script-terminating (runspace-terminating) error"

This PR makes all error-related docs consistent with vocabulary the repo already uses.


Scope and limitations

Note

What this PR does NOT do — and what I'm uncertain about.

In scope
reference/7.6/ about_ topics, the index, and the conceptual deep-dive article
Out of scope: older versions (5.1, 7.4, 7.5)
The same inaccuracies exist in all older version folders. I've audited them and know the exact lines. Whether they should be backported in this PR or a follow-up is the maintainer's call — I'm happy either way. I haven't touched them because I didn't want to inflate the diff before getting alignment on the 7.6 changes.
Out of scope: cmdlet reference files
Write-Error.md, Set-StrictMode.md, and a few other cmdlet pages use "terminating error" without qualification. Fixing those is a different review surface (cmdlet docs vs conceptual docs) and I think it's better as a separate PR — but I could be wrong. Open to guidance.
Not verified: edge cases in constrained language mode
All source verification was done against the default FullLanguage mode. I haven't verified whether ConstrainedLanguage mode changes any of these behaviors. The engine source suggests it doesn't, but I want to be transparent that I haven't tested it.
Not verified: PowerShell 5.1 behavioral differences
The source citations reference the 7.x codebase. PowerShell 5.1 (Windows PowerShell) has a different engine. The three-category model applies there too, but some edge cases (like throw suppression) may behave differently. The 5.1 docs should be verified independently before backporting.

Related

Link
Fixes #1583 (open 9 years, 78 reactions)
References #1424 (original suggestion for about_Error_Handling)
Engine source PowerShell/PowerShell (verified against 7.x)

PR Checklist

  • Descriptive Title: This PR's title is a synopsis of the changes it proposes.
  • Summary: This PR's summary describes the scope and intent of the change.
  • Contributor's Guide: I have read the contributor's guide.
  • Style: This PR adheres to the style guide.
  • Terminology: Uses existing "statement-terminating" / "script-terminating" terms already present in this repo.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit bf58d3d:

✅ Validation status: passed

File Status Preview URL Details
.github/workflows/retarget-7.7.yml ✅Succeeded
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@SufficientDaikon SufficientDaikon force-pushed the docs/error-handling-overhaul branch from bf58d3d to 94b6c6e Compare March 26, 2026 20:15
@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 94b6c6e:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 397f608:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@SufficientDaikon SufficientDaikon force-pushed the docs/error-handling-overhaul branch from 397f608 to 94b6c6e Compare March 27, 2026 02:26
@SufficientDaikon SufficientDaikon marked this pull request as ready for review March 27, 2026 02:27
@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 94b6c6e:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 020931e:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit fd972ca:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@SufficientDaikon
Copy link
Copy Markdown
Contributor Author

@mklement0 anything else?

@mklement0

This comment was marked as resolved.

@SufficientDaikon
Copy link
Copy Markdown
Contributor Author

SufficientDaikon commented Mar 28, 2026

A few more comments coming...

@mkelement0 some of mine too

@mklement0
Copy link
Copy Markdown
Contributor

A few high-level observations, which in part may require corrections in multiple places:

  • $ErrorActionPreference acts on throw too, both with SilentlyContinue and Ignore.

    • When passed to advanced scripts / functions / script blocks (which are the only ones that support common parameters), even -ErrorAction SilentlyContinue/Ignore suppress throw, because the common parameter gets translated into a scope-local $ErrorActionPreference with that value.

    • However, is worth noting that Ignore isn't capable of preventing either a statement- or a script-terminating error from getting recorded in $Error.

  • Re statement-terminating errors (something I only just now discovered):

    • $ErrorActionPreference = 'Stop' is only capable of escalating them to script-terminating ones inside non-advanced scripts / functions / script blocks.
    • In advanced ones they remain statement-terminating ones.
      • Note that this also applies to passing -ErrorAction Stop to advanced ones, given that (as noted), this implicitly translates to a function-local $ErrorActionPreference = 'Stop' setting.
# NON-advanced script block: *script*-terminating error ('after' doesn't print)
& { param() $ErrorActionPreference = 'Stop'; gi -nosuch }; 'after'

# ADVANCED script block: *statement*-terminating error ('after' prints).
& { [cmdletbinding()]param() $ErrorActionPreference = 'Stop'; gi -nosuch }; 'after'

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 0808e1d:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@SufficientDaikon
Copy link
Copy Markdown
Contributor Author

SufficientDaikon commented Mar 28, 2026

@mklement0 — Thank you for this. These are exactly the kinds of corrections that make me glad I opened this PR rather than leaving the docs as they were.

1. $ErrorActionPreference acts on throw

You're right — I verified this and my claim ("regardless of $ErrorActionPreference") was wrong. Both SilentlyContinue and Ignore suppress throw, and -ErrorAction SilentlyContinue on advanced functions translates to a scope-local $ErrorActionPreference, so it suppresses throw too. Fixed — the throw section now documents this accurately.

2. Ignore and $Error recording

Confirmed — $Error.Count is 1 even with $ErrorActionPreference = 'Ignore' after a throw. Added a NOTE callout and updated the $Error variable section to distinguish non-terminating (Ignore prevents recording) from terminating (Ignore does not prevent recording).

3. Advanced vs. non-advanced escalation

The escalation section now documents this distinction with your exact example pattern. I also changed the -ErrorAction Stop row and about_CommonParameters to say "terminating error" generically rather than overclaiming "script-terminating", with the escalation section providing the full context-dependent explanation.

All three fixes pushed in bc5e604 and a1c3c06. I'd really value a follow-up pass from you on the revised escalation section — your source-level knowledge of these paths is what makes this documentation accurate rather than "close enough."

generated by opus.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit a1c3c06:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@SufficientDaikon
Copy link
Copy Markdown
Contributor Author

@mklement0 sorry about my comments being generated by ai, i'm working on dialing it down

anyhow, i appreciate your replies and engagment it's really helpful for me to make the PR better, so yea i'll only tag you from now on IF i need input, otherwise i'll just keeping working on this till it's good enough to be merged.

have a good weekend!

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 598d241:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 073bf1c:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/About.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 62b791b:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/About.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

SufficientDaikon and others added 8 commits April 2, 2026 08:28
Create a comprehensive about_Error_Handling reference topic that documents
PowerShell's three error categories: non-terminating, statement-terminating,
and script-terminating errors. Correct false claims in about_CommonParameters
and about_Preference_Variables that state -ErrorAction and
$ErrorActionPreference have "no effect on terminating errors." Update
about_Try_Catch_Finally, about_Throw, about_Trap, and
everything-about-exceptions to use precise terminology consistent with
existing usage in about_Calculated_Properties, about_Pipeline_Chain_Operators,
and about_Pwsh.

Fixes MicrosoftDocs#1583
- -ErrorAction Stop promotes to script-terminating, not statement-terminating
- $ErrorActionPreference applies to both non-terminating and
  statement-terminating errors (unlike -ErrorAction parameter)
- $ErrorActionPreference = 'Ignore' is now accepted (remove outdated caveat)
- Native command non-zero exit emits non-terminating NativeCommandExitException

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…se errors

Major corrections verified against PowerShell engine source code:

- Fix: -ErrorAction Stop produces script-terminating errors, not
  statement-terminating. ActionPreferenceStopException sets
  SuppressPromptInInterpreter=true, causing call-stack unwinding.
  Fixed across all 4 affected files.

- Add: New "$ErrorActionPreference asymmetry" section in
  about_Error_Handling documenting that $ErrorActionPreference applies
  to BOTH non-terminating and statement-terminating errors, while
  -ErrorAction only affects non-terminating errors. Includes runnable
  demo and IMPORTANT callout for exceptions (SuppressPromptInInterpreter,
  PS classes, PipelineStoppedException).

- Add: Parse errors to script-terminating generators list (per
  mklement0 review comment).

- Fix: about_Preference_Variables Ignore bullet incorrectly stated
  "Ignore isn't a valid value for $ErrorActionPreference" — it is
  accepted (only Suspend is rejected per ExecutionContext.cs).

- Fix: NOTE block on ThrowTerminatingError now correctly explains
  that $ErrorActionPreference can suppress it via the engine's
  statement-level handler in MiscOps.CheckActionPreference.

- Fix: Summary table updated — -ErrorAction Stop moved from
  statement-terminating to script-terminating column, new row added
  for $ErrorActionPreference behavior per error type.

- Fix: everything-about-exceptions.md — three remaining instances of
  vague "terminating error" updated to "script-terminating error" for
  throw and -ErrorAction Stop contexts.

All claims verified with live PowerShell 7.x tests:
  1. -ErrorAction Stop: next statement in scriptblock does NOT run (script-terminating)
  2. Parse errors: caught as MethodInvocationException
  3. $ErrorActionPreference='Ignore': accepted without error
  4. $ErrorActionPreference='SilentlyContinue': suppresses ThrowTerminatingError
  5. -ErrorAction SilentlyContinue: does NOT suppress ThrowTerminatingError

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…d escalation

Three corrections based on mklement0's review:

1. throw CAN be suppressed by $ErrorActionPreference when set to
   SilentlyContinue or Ignore. Removed the incorrect claim that throw
   is "always" script-terminating "regardless of $ErrorActionPreference".
   Also documented that -ErrorAction on advanced functions translates
   to a scope-local $ErrorActionPreference, so it suppresses throw too.

2. Added NOTE that $ErrorActionPreference = 'Ignore' still records
   terminating errors in $Error. Ignore only prevents $Error recording
   for non-terminating errors.

3. Escalation section now documents the advanced vs. non-advanced
   distinction: $ErrorActionPreference = 'Stop' produces
   script-terminating errors in non-advanced contexts, but
   statement-terminating errors in advanced contexts ([CmdletBinding()]).
   Summary table updated to reflect both contexts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ript-terminating

Per mklement0 feedback, -ErrorAction Stop escalation scope depends on
whether the context is advanced ([CmdletBinding()]) or non-advanced.
Changed about_CommonParameters.md and ErrorAction table to say
"terminating error" generically, with escalation section providing
the full advanced vs. non-advanced explanation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- about_Throw: Add $ErrorActionPreference suppression caveat (throw CAN
  be suppressed by SilentlyContinue/Ignore), add NOTE block with Ignore
  still recording in $Error, update description to "by default"
- about_Try_Catch_Finally: Add NOTE about throw suppression with cross-ref
  to about_Error_Handling, fix $tempPath -> $tempFile code bug (line 264)
- about_Preference_Variables: Fix Ignore bullet - clarify that Ignore only
  prevents $Error recording for non-terminating errors, not terminating
- everything-about-exceptions: Change -ErrorAction Stop from
  "script-terminating" to "terminating" (context-dependent behavior)

All claims verified against live PowerShell 7.6 behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- About.md: Update throw index to "script-terminating error by default"
- about_Automatic_Variables: Qualify $Error/Ignore as non-terminating only
- about_CommonParameters: Qualify Ignore bullet as non-terminating only

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- About.md: Add missing about_Error_Handling entry to topic index
- About.md: Update about_Trap and about_Try_Catch_Finally descriptions
  to say "statement-terminating and script-terminating errors"
- about_Try_Catch_Finally.md: Fix [07] link text to match target heading
- Update ms.date on about_Trap, about_CommonParameters,
  about_Preference_Variables, everything-about-exceptions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sdwheeler sdwheeler force-pushed the docs/error-handling-overhaul branch from 62b791b to 8ebe0df Compare April 2, 2026 13:31
@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 8ebe0df:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/About.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@sdwheeler
Copy link
Copy Markdown
Collaborator

@SufficientDaikon Thank you very much for your work here. This has been a tough subject to organize. You did a great job presenting the information and standardizing the terminology.

In commit 087687f I made editorial changes. Most were formatting. Some wording changes for style and voice. But nothing factual should have changed.

I will now work on copying these changes to the other versions before we merge.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 087687f:

✅ Validation status: passed

File Status Preview URL Details
reference/7.6/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/About.md ✅Succeeded View (powershell-7.6)
reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md ✅Succeeded View (>=powershell-5.1)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 8cc25cb:

✅ Validation status: passed

File Status Preview URL Details
reference/5.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-5.1)
reference/5.1/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-5.1)
reference/5.1/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-5.1)
reference/5.1/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-5.1)
reference/5.1/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-5.1)
reference/5.1/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-5.1)
reference/5.1/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-5.1)
reference/7.4/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.4)
reference/7.4/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.4)
reference/7.4/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.4)
reference/7.4/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.4)
reference/7.4/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.4)
reference/7.4/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.4)
reference/7.4/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.4)
reference/7.5/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.5)
reference/7.5/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.5)
reference/7.5/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.5)
reference/7.5/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.5)
reference/7.5/Microsoft.PowerShell.Core/About/about_Throw.md ✅Succeeded View (powershell-7.5)
reference/7.5/Microsoft.PowerShell.Core/About/about_Trap.md ✅Succeeded View (powershell-7.5)
reference/7.5/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md ✅Succeeded View (powershell-7.5)
reference/7.6/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md ✅Succeeded View (powershell-7.6)
reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md ✅Succeeded View (powershell-7.6)

This comment lists only the first 25 files in the pull request.
For more details, please refer to the build report.

@sdwheeler sdwheeler merged commit 7baf667 into MicrosoftDocs:main Apr 2, 2026
5 checks passed
@SufficientDaikon
Copy link
Copy Markdown
Contributor Author

@sdwheeler aw, it's comments like that that make me feel that all the copilot premium requests I spent on this were worth it.

Do you need anything else from me or is this done?

@sdwheeler
Copy link
Copy Markdown
Collaborator

Do you need anything else from me or is this done?

It's done and merged. If you find any errors, please feel free to submit fixes 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants