Skip to content

PS7: Get-Error should report the fully-qualified error name #11106

@JustinGrote

Description

@JustinGrote

Summary of the new feature/enhancement

Get-Error reports fullyqualifiederrorid without its namespace. This can make it difficult to find the fully qualified exception for use in catch statements, especially if running in Azure Functions or other environments with custom exceptions and you only have text logs to go off of. Since the major point of Get-Error is to address exceptions and perhaps catch them, the fully qualified type is important to do a specific catch, as my most common workflow when looking at errors is doing $error[0].exception.gettype().fullname as the very next step so I know what to use in a try/catch.

Proposed technical implementation details (optional)

Add FullyQualifiedErrorType and FullyQualifiedErrorParentType properties that would display the full error type (what you would submit as a type to catch) as well as other error types that would catch this property, minus the obvious "system.exception" and "system.object" that all exceptions inherit from.

e.g.
FullyQualifiedErrorType:

$error[0].exception.gettype()

FullyQualifiedErrorParentTypes:

$currentType = $error[0].exception.getType()
while ($CurrentType) {
    $currentType = $currentType.BaseType
    if ($currentType.fullname -eq 'System.Exception') {break}
    $currentType
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions