Skip to content

Add Type member to Exceptions containing type of exception for Get-Error - #11076

Merged
Travis Plunk (TravisEz13) merged 4 commits into
PowerShell:masterfrom
SteveL-MSFT:get-error-exception-type
Nov 22, 2019
Merged

Travis Plunk (TravisEz13) merged 4 commits into
PowerShell:masterfrom
SteveL-MSFT:get-error-exception-type

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 14, 2019 •

Copy link
Copy Markdown
Member

PR Summary

For Get-Error cmdlet, if the object (or nested object) is an Exception, we add an ExceptionType property that has the full type name. The Exception type is useful information and this change doesn't require the user to explore the error object to get it.

Example:

PS> 1/0
RuntimeException: Attempted to divide by zero.
PS> gerr

Exception             :
    ExceptionType  : System.Management.Automation.RuntimeException
    ErrorRecord    :
        Exception             :
            ExceptionType : System.Management.Automation.ParentContainsErrorRecordException
            Message       : Attempted to divide by zero.
            HResult       : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : RuntimeException
        InvocationInfo        :
            ScriptLineNumber : 1
            OffsetInLine     : 1
            HistoryId        : -1
            Line             : 1/0
            PositionMessage  : At line:1 char:1
                               + 1/0
                               + ~~~
            CommandOrigin    : Internal
        ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    TargetSite     :
        Name          : Divide
        DeclaringType : System.Management.Automation.IntOps
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace     :
   at System.Management.Automation.IntOps.Divide(Int32 lhs, Int32 rhs) in /Users/steve/repos/PowerShell/src/System.Management.Automation/engine/runtime/Operations/NumericOps.cs:line 61
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) in /Users/steve/repos/PowerShell/src/System.Management.Automation/engine/interpreter/DynamicInstructions.Generated.cs:line 166
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in /Users/steve/repos/PowerShell/src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs:line 357
    Message        : Attempted to divide by zero.
    Data           : System.Collections.ListDictionaryInternal
    InnerException :
        ExceptionType : System.DivideByZeroException
        Message       : Attempted to divide by zero.
        HResult       : -2147352558
    Source         : System.Management.Automation
    HResult        : -2146233087
CategoryInfo          : NotSpecified: (:) [], RuntimeException
FullyQualifiedErrorId : RuntimeException
InvocationInfo        :
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : -1
    Line             : 1/0
    PositionMessage  : At line:1 char:1
                       + 1/0
                       + ~~~
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

PR Checklist

@TravisEz13

Copy link
Copy Markdown
Member

PoshChan-Bot (@PoshChan) Please remind me in 1 hour

@PoshChan

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13), this is the reminder you requested 1 hour ago

@TravisEz13

Copy link
Copy Markdown
Member

PoshChan-Bot (@PoshChan) Please remind me in 1 hour

@PoshChan

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13), this is the reminder you requested 1 hour ago

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 16, 2019
@iSazonov Ilya (iSazonov) added this to the 7.0.0-preview.6 milestone Nov 16, 2019
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

changed property name from ExceptionType to just Type based on Michael Klement (@mklement0)'s feedback

@SteveL-MSFT Steve Lee (SteveL-MSFT) changed the title Add ExceptionType member to Exceptions for Get-Error Add Type member to Exceptions containing type of exception for Get-Error Nov 19, 2019
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) please retry windows

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

CodeFactor issue is by-design

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-Windows

@ghost

Copy link
Copy Markdown

🎉v7.0.0-rc.2 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants