Summary of the new feature/enhancement
Update: The issue is primarily that a nested ErrorRecord: prints duplicate information, which results in "noisy" output that is hard to parse; see the discussion in the comments.
Currently, when Get-Error pretty-prints an error, the information about the error record's .Exception and Exception.InnerException values are pretty far apart.
It would be helpful if they were grouped together in the output.
Currently (look for <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< markers; note that in this simple example the messages happen to be the same, but that's not typical):
Exception :
ErrorRecord :
Exception : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Message : Attempted to divide by zero.
Data : System.Collections.ListDictionaryInternal
InnerException : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Message : Attempted to divide by zero.
HResult : -2147352558
Desired:
Exception :
ErrorRecord :
Exception : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Message : Attempted to divide by zero.
HResult : -2146233087
InnerException : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Message : Attempted to divide by zero.
HResult : -2147352558
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)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Message : Attempted to divide by zero.
Data : System.Collections.ListDictionaryInternal
Summary of the new feature/enhancement
Update: The issue is primarily that a nested
ErrorRecord:prints duplicate information, which results in "noisy" output that is hard to parse; see the discussion in the comments.Currently, when
Get-Errorpretty-prints an error, the information about the error record's.ExceptionandException.InnerExceptionvalues are pretty far apart.It would be helpful if they were grouped together in the output.
Currently (look for
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<markers; note that in this simple example the messages happen to be the same, but that's not typical):Exception : ErrorRecord : Exception : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 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) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) Message : Attempted to divide by zero. Data : System.Collections.ListDictionaryInternal InnerException : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Message : Attempted to divide by zero. HResult : -2147352558Desired:
Exception : ErrorRecord : Exception : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Message : Attempted to divide by zero. HResult : -2146233087 InnerException : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Message : Attempted to divide by zero. HResult : -2147352558 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) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) Message : Attempted to divide by zero. Data : System.Collections.ListDictionaryInternal