-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
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
}