Skip to content

Add a property to [System.Management.Automation.ErrorRecord] to distinguish error types (non-terminating, statement-terminating, script-terminating) #4781

@mklement0

Description

@mklement0

As requested in #3158 and suggested by @SteveL-MSFT
in #3647 (comment).

Currently, you cannot derive from a [System.Management.Automation.ErrorRecord] instance whether it represents a non-terminating, a statement-terminating, or a script-terminating error.

Note that, on the command line, you can already detect a script-terminating error generated with a Throw statement by examining the relevant $Error collection entry's .Exception.WasThrownFromThrowStatement property, but that won't work for errors that were promoted to script-terminating ones via -ErrorAction Stop / $ErrorActionPreference = 'Stop' (such errors generate an accompanying [System.Management.Automation.ActionPreferenceStopException] error).

One useful application for allowing the discovery of a given error's "fatality" would be to enable error-type-specific coloring of error output, as discussed in the context of improving the standard error view in #3647.

Also see the expanded proposal below, which asks for two properties: the intrinsic severity, and the effective severity.

Environment data

PowerShell Core v6.0.0-beta.6

Metadata

Metadata

Assignees

Labels

Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions