Sometimes it is hard to track down where an error message came from and also what the exact error actually is. Also, actual error details can sometimes be hidden in $_.Exception.InnerException and there can be more than one of these. Thus, it would be nice if the toolkit had a method of displaying a standard set of the most useful error message details using a method which can display all InnerExceptions if they exist.
In my opinion, the most useful error message details are as such: Message, FullyQualifiedErrorId, ScriptStackTrace, PositionMessage, InnerException. The function is versatile enough so that you can specify whatever properties you which to display for the error record.
Also, I have written a working solution for what I have just described. Another plus for having a function that deals with display error message details is that if you use a cmdlet and specify the -ErrorVariable parameter for it, you can then examine/log all of the error messages that cmdlet produced using my function.
To use this function in the toolkit, we would simply need to replace every spot where we display error information with a call to the function like such:
Write-Log "Failed to install MSI $(Resolve-Error)"
In my opinion, the most useful error message details are as such: Message, FullyQualifiedErrorId, ScriptStackTrace, PositionMessage, InnerException. The function is versatile enough so that you can specify whatever properties you which to display for the error record.
Also, I have written a working solution for what I have just described. Another plus for having a function that deals with display error message details is that if you use a cmdlet and specify the -ErrorVariable parameter for it, you can then examine/log all of the error messages that cmdlet produced using my function.
To use this function in the toolkit, we would simply need to replace every spot where we display error information with a call to the function like such:
Write-Log "Failed to install MSI $(Resolve-Error)"